Bug 784739 - Switch from NULL to nullptr in widget/android/; r=ehsan

This commit is contained in:
Birunthan Mohanathas 2013-10-10 16:42:52 -04:00
parent 3bd29c41c6
commit fc33fdaccd
9 changed files with 75 additions and 75 deletions

View File

@ -77,7 +77,7 @@ jclass AndroidBridge::GetClassGlobalRef(JNIEnv* env, const char* className)
}
// Local ref no longer necessary because we have a global ref.
env->DeleteLocalRef(classLocalRef);
classLocalRef = NULL;
classLocalRef = nullptr;
return static_cast<jclass>(classGlobalRef);
}
@ -238,7 +238,7 @@ jstring AndroidBridge::NewJavaString(JNIEnv* env, const PRUnichar* string, uint3
ALOG_BRIDGE("Exceptional exit of: %s", __PRETTY_FUNCTION__);
env->ExceptionDescribe();
env->ExceptionClear();
return NULL;
return nullptr;
}
return ret;
}
@ -676,13 +676,13 @@ AndroidBridge::SetLayerClient(JNIEnv* env, jobject jobj)
// and we had to recreate it, but all the Gecko-side things were not destroyed.
// We therefore need to link up the new java objects to Gecko, and that's what
// we do here.
bool resetting = (mLayerClient != NULL);
bool resetting = (mLayerClient != nullptr);
if (resetting) {
// clear out the old layer client
env->DeleteGlobalRef(mLayerClient->wrappedObject());
delete mLayerClient;
mLayerClient = NULL;
mLayerClient = nullptr;
}
AndroidGeckoLayerClient *client = new AndroidGeckoLayerClient();
@ -726,18 +726,18 @@ EGLSurface
AndroidBridge::ProvideEGLSurface()
{
if (!jEGLSurfacePointerField) {
return NULL;
return nullptr;
}
MOZ_ASSERT(mGLControllerObj, "AndroidBridge::ProvideEGLSurface called with a null GL controller ref");
JNIEnv* env = GetJNIForThread(); // called on the compositor thread
if (!env) {
return NULL;
return nullptr;
}
jobject eglSurface = ProvideEGLSurfaceWrapper(mGLControllerObj);
if (!eglSurface)
return NULL;
return nullptr;
EGLSurface ret = reinterpret_cast<EGLSurface>(env->GetIntField(eglSurface, jEGLSurfacePointerField));
env->DeleteLocalRef(eglSurface);
@ -1399,13 +1399,13 @@ AndroidBridge::LockWindow(void *window, unsigned char **bits, int *width, int *h
};
int err;
*bits = NULL;
*bits = nullptr;
*width = *height = *format = 0;
if (mHasNativeWindowAccess) {
ANativeWindow_Buffer buffer;
if ((err = ANativeWindow_lock(window, (void*)&buffer, NULL)) != 0) {
if ((err = ANativeWindow_lock(window, (void*)&buffer, nullptr)) != 0) {
ALOG_BRIDGE("ANativeWindow_lock failed! (error %d)", err);
return false;
}
@ -1418,7 +1418,7 @@ AndroidBridge::LockWindow(void *window, unsigned char **bits, int *width, int *h
} else if (mHasNativeWindowFallback) {
SurfaceInfo info;
if ((err = Surface_lock(window, &info, NULL, true)) != 0) {
if ((err = Surface_lock(window, &info, nullptr, true)) != 0) {
ALOG_BRIDGE("Surface_lock failed! (error %d)", err);
return false;
}
@ -1538,8 +1538,8 @@ void AndroidBridge::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZo
}
AndroidBridge::AndroidBridge()
: mLayerClient(NULL),
mNativePanZoomController(NULL)
: mLayerClient(nullptr),
mNativePanZoomController(nullptr)
{
}
@ -1594,7 +1594,7 @@ static void
JavaThreadDetachFunc(void *arg)
{
JNIEnv *env = (JNIEnv*) arg;
JavaVM *vm = NULL;
JavaVM *vm = nullptr;
env->GetJavaVM(&vm);
vm->DetachCurrentThread();
}
@ -1603,11 +1603,11 @@ extern "C" {
__attribute__ ((visibility("default")))
JNIEnv * GetJNIForThread()
{
JNIEnv *jEnv = NULL;
JNIEnv *jEnv = nullptr;
JavaVM *jVm = mozilla::AndroidBridge::GetVM();
if (!jVm) {
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "Returned a null VM");
return NULL;
return nullptr;
}
jEnv = static_cast<JNIEnv*>(PR_GetThreadPrivate(sJavaEnvThreadIndex));
@ -1617,10 +1617,10 @@ extern "C" {
int status = jVm->GetEnv((void**) &jEnv, JNI_VERSION_1_2);
if (status) {
status = jVm->AttachCurrentThread(&jEnv, NULL);
status = jVm->AttachCurrentThread(&jEnv, nullptr);
if (status) {
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "Could not attach");
return NULL;
return nullptr;
}
PR_SetThreadPrivate(sJavaEnvThreadIndex, jEnv);

View File

@ -227,7 +227,7 @@ public:
void GetIconForExtension(const nsACString& aFileExt, uint32_t aIconSize, uint8_t * const aBuf);
// Switch Java to composite with the Gecko Compositor thread
void RegisterCompositor(JNIEnv* env = NULL);
void RegisterCompositor(JNIEnv* env = nullptr);
EGLSurface ProvideEGLSurface();
bool GetStaticStringField(const char *classID, const char *field, nsAString &result, JNIEnv* env = nullptr);
@ -429,7 +429,7 @@ public:
class AutoJObject {
public:
AutoJObject(JNIEnv* aJNIEnv = NULL) : mObject(NULL)
AutoJObject(JNIEnv* aJNIEnv = nullptr) : mObject(nullptr)
{
mJNIEnv = aJNIEnv ? aJNIEnv : AndroidBridge::GetJNIEnv();
}
@ -484,7 +484,7 @@ public:
void Purge() {
if (mJNIEnv) {
if (mHasFrameBeenPushed)
mJNIEnv->PopLocalFrame(NULL);
mJNIEnv->PopLocalFrame(nullptr);
Push();
}
}
@ -510,7 +510,7 @@ public:
CheckForException();
if (mHasFrameBeenPushed)
mJNIEnv->PopLocalFrame(NULL);
mJNIEnv->PopLocalFrame(nullptr);
}
private:

View File

@ -17,7 +17,7 @@ AndroidDirectTexture::AndroidDirectTexture(uint32_t width, uint32_t height, uint
, mWidth(width)
, mHeight(height)
, mFormat(format)
, mPendingReallocBuffer(NULL)
, mPendingReallocBuffer(nullptr)
{
mFrontBuffer = new AndroidGraphicBuffer(width, height, usage, format);
mBackBuffer = new AndroidGraphicBuffer(width, height, usage, format);
@ -27,12 +27,12 @@ AndroidDirectTexture::~AndroidDirectTexture()
{
if (mFrontBuffer) {
delete mFrontBuffer;
mFrontBuffer = NULL;
mFrontBuffer = nullptr;
}
if (mBackBuffer) {
delete mBackBuffer;
mBackBuffer = NULL;
mBackBuffer = nullptr;
}
}
@ -46,7 +46,7 @@ AndroidDirectTexture::ReallocPendingBuffer()
// It is assumed that mLock is already acquired
if (mPendingReallocBuffer == mBackBuffer) {
mBackBuffer->Reallocate(mWidth, mHeight, mFormat);
mPendingReallocBuffer = NULL;
mPendingReallocBuffer = nullptr;
}
}

View File

@ -265,18 +265,18 @@ AndroidGraphicBuffer::DestroyBuffer()
if (mEGLImage) {
if (sGLFunctions.EnsureInitialized()) {
sGLFunctions.fDestroyImageKHR(sGLFunctions.fGetDisplay(EGL_DEFAULT_DISPLAY), mEGLImage);
mEGLImage = NULL;
mEGLImage = nullptr;
}
}
#endif
mEGLImage = NULL;
mEGLImage = nullptr;
if (mHandle) {
if (sGLFunctions.EnsureInitialized()) {
sGLFunctions.fGraphicBufferDtor(mHandle);
}
free(mHandle);
mHandle = NULL;
mHandle = nullptr;
}
}
@ -413,7 +413,7 @@ AndroidGraphicBuffer::EnsureEGLImage()
void* nativeBuffer = sGLFunctions.fGraphicBufferGetNativeBuffer(mHandle);
mEGLImage = sGLFunctions.fCreateImageKHR(sGLFunctions.fGetDisplay(EGL_DEFAULT_DISPLAY), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)nativeBuffer, eglImgAttrs);
return mEGLImage != NULL;
return mEGLImage != nullptr;
}
bool
@ -445,7 +445,7 @@ static const char* const sAllowedBoards[] = {
"sgh-i997", // Samsung Infuse 4G
"herring", // Samsung Nexus S
"sgh-t839", // Samsung Sidekick 4G
NULL
nullptr
};
bool

View File

@ -813,7 +813,7 @@ Java_org_mozilla_gecko_GeckoAppShell_getNextMessageFromQueue(JNIEnv* jenv, jclas
}
if (!jMessageQueueCls || !jNextMethod)
return NULL;
return nullptr;
if (jMessagesField) {
jobject msg = jenv->GetObjectField(queue, jMessagesField);
@ -821,7 +821,7 @@ Java_org_mozilla_gecko_GeckoAppShell_getNextMessageFromQueue(JNIEnv* jenv, jclas
// It turns out to be an order of magnitude more performant to do this extra check here and
// block less vs. one fewer checks here and more blocking.
if (!msg) {
return NULL;
return nullptr;
}
}
return jenv->CallObjectMethod(queue, jNextMethod);
@ -905,7 +905,7 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy(JNIEnv* env, jobject
return;
}
jobject oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(NULL);
jobject oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(nullptr);
if (!oldRef) {
MOZ_ASSERT(false, "Clearing a non-existent NPZC");
} else {
@ -966,7 +966,7 @@ Java_org_mozilla_gecko_ANRReporter_requestNativeStack(JNIEnv*, jclass)
// Buffer one sample and let the profiler wait a long time
profiler_start(100, 10000, NATIVE_STACK_FEATURES,
sizeof(NATIVE_STACK_FEATURES) / sizeof(char*),
NULL, 0);
nullptr, 0);
return JNI_TRUE;
}
@ -975,7 +975,7 @@ Java_org_mozilla_gecko_ANRReporter_getNativeStack(JNIEnv* jenv, jclass)
{
if (!profiler_is_active()) {
// Maybe profiler support is disabled?
return NULL;
return nullptr;
}
char *profile = profiler_get_profile();
while (profile && !strlen(profile)) {
@ -983,7 +983,7 @@ Java_org_mozilla_gecko_ANRReporter_getNativeStack(JNIEnv* jenv, jclass)
sched_yield();
profile = profiler_get_profile();
}
jstring result = NULL;
jstring result = nullptr;
if (profile) {
result = jenv->NewStringUTF(profile);
free(profile);

View File

@ -45,7 +45,7 @@ extern "C" {
// to missing the classpath
MOZ_ASSERT(NS_IsMainThread());
JNIEnv *env = mozilla::AndroidBridge::GetJNIEnv();
if (!env) return NULL;
if (!env) return nullptr;
return env->FindClass(className);
}
@ -55,7 +55,7 @@ extern "C" {
JNIEnv *env = mozilla::AndroidBridge::GetJNIEnv();
jclass globalRef = static_cast<jclass>(env->NewGlobalRef(env->FindClass(className)));
if (!globalRef)
return NULL;
return nullptr;
// return the newly create global reference
return globalRef;
@ -73,7 +73,7 @@ extern "C" {
&foundClass));
mainThread->Dispatch(runnable_ref, NS_DISPATCH_SYNC);
if (!foundClass)
return NULL;
return nullptr;
return foundClass;
}
@ -84,7 +84,7 @@ extern "C" {
const char *methodName,
const char *signature) {
JNIEnv *env = mozilla::AndroidBridge::GetJNIEnv();
if (!env) return NULL;
if (!env) return nullptr;
return env->GetStaticMethodID(methodClass, methodName, signature);
}
@ -92,7 +92,7 @@ extern "C" {
bool
jsjni_ExceptionCheck() {
JNIEnv *env = mozilla::AndroidBridge::GetJNIEnv();
if (!env) return NULL;
if (!env) return nullptr;
return env->ExceptionCheck();
}

View File

@ -137,7 +137,7 @@ jfieldID AndroidProgressiveUpdateData::jShouldAbortField = 0;
RefCountedJavaObject::~RefCountedJavaObject() {
if (mObject)
GetJNIForThread()->DeleteGlobalRef(mObject);
mObject = NULL;
mObject = nullptr;
}
void
@ -233,19 +233,19 @@ AndroidLocation::CreateGeoPosition(JNIEnv *jenv, jobject jobj)
AutoLocalJNIFrame jniFrame(jenv);
double latitude = jenv->CallDoubleMethod(jobj, jGetLatitudeMethod);
if (jniFrame.CheckForException()) return NULL;
if (jniFrame.CheckForException()) return nullptr;
double longitude = jenv->CallDoubleMethod(jobj, jGetLongitudeMethod);
if (jniFrame.CheckForException()) return NULL;
if (jniFrame.CheckForException()) return nullptr;
double altitude = jenv->CallDoubleMethod(jobj, jGetAltitudeMethod);
if (jniFrame.CheckForException()) return NULL;
if (jniFrame.CheckForException()) return nullptr;
float accuracy = jenv->CallFloatMethod (jobj, jGetAccuracyMethod);
if (jniFrame.CheckForException()) return NULL;
if (jniFrame.CheckForException()) return nullptr;
float bearing = jenv->CallFloatMethod (jobj, jGetBearingMethod);
if (jniFrame.CheckForException()) return NULL;
if (jniFrame.CheckForException()) return nullptr;
float speed = jenv->CallFloatMethod (jobj, jGetSpeedMethod);
if (jniFrame.CheckForException()) return NULL;
if (jniFrame.CheckForException()) return nullptr;
long long time = jenv->CallLongMethod (jobj, jGetTimeMethod);
if (jniFrame.CheckForException()) return NULL;
if (jniFrame.CheckForException()) return nullptr;
return new nsGeoPosition(latitude, longitude,
altitude, accuracy,
@ -394,7 +394,7 @@ AndroidGeckoEvent::ReadIntArray(nsTArray<int> &aVals,
int32_t count)
{
jintArray jIntArray = (jintArray)jenv->GetObjectField(wrapped_obj, field);
jint *vals = jenv->GetIntArrayElements(jIntArray, NULL);
jint *vals = jenv->GetIntArrayElements(jIntArray, nullptr);
for (int32_t i = 0; i < count; i++) {
aVals.AppendElement(vals[i]);
}
@ -408,7 +408,7 @@ AndroidGeckoEvent::ReadFloatArray(nsTArray<float> &aVals,
int32_t count)
{
jfloatArray jFloatArray = (jfloatArray)jenv->GetObjectField(wrapped_obj, field);
jfloat *vals = jenv->GetFloatArrayElements(jFloatArray, NULL);
jfloat *vals = jenv->GetFloatArrayElements(jFloatArray, nullptr);
for (int32_t i = 0; i < count; i++) {
aVals.AppendElement(vals[i]);
}
@ -1354,7 +1354,7 @@ nsJNIString::nsJNIString(jstring jstr, JNIEnv *jenv)
return;
}
}
const jchar* jCharPtr = jni->GetStringChars(jstr, NULL);
const jchar* jCharPtr = jni->GetStringChars(jstr, nullptr);
if (!jCharPtr) {
SetIsVoid(true);

View File

@ -64,22 +64,22 @@ NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
NS_DEFINE_NAMED_CID(NS_ANDROIDBRIDGE_CID);
static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_WINDOW_CID, false, NULL, nsWindowConstructor },
{ &kNS_CHILD_CID, false, NULL, nsWindowConstructor },
{ &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor },
{ &kNS_SCREENMANAGER_CID, false, NULL, nsScreenManagerAndroidConstructor },
{ &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceAndroidConstructor },
{ &kNS_TRANSFERABLE_CID, false, NULL, nsTransferableConstructor },
{ &kNS_CLIPBOARD_CID, false, NULL, nsClipboardConstructor },
{ &kNS_CLIPBOARDHELPER_CID, false, NULL, nsClipboardHelperConstructor },
{ &kNS_PRINTSETTINGSSERVICE_CID, false, NULL, nsPrintOptionsAndroidConstructor },
{ &kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor },
{ &kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecAndroidConstructor },
{ &kNS_HTMLFORMATCONVERTER_CID, false, NULL, nsHTMLFormatConverterConstructor },
{ &kNS_IMEPICKER_CID, false, NULL, nsIMEPickerConstructor },
{ &kNS_GFXINFO_CID, false, NULL, mozilla::widget::GfxInfoConstructor },
{ &kNS_ANDROIDBRIDGE_CID, false, NULL, nsAndroidBridgeConstructor },
{ NULL }
{ &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor },
{ &kNS_CHILD_CID, false, nullptr, nsWindowConstructor },
{ &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor },
{ &kNS_SCREENMANAGER_CID, false, nullptr, nsScreenManagerAndroidConstructor },
{ &kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceAndroidConstructor },
{ &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor },
{ &kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor },
{ &kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor },
{ &kNS_PRINTSETTINGSSERVICE_CID, false, nullptr, nsPrintOptionsAndroidConstructor },
{ &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor },
{ &kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, nsDeviceContextSpecAndroidConstructor },
{ &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor },
{ &kNS_IMEPICKER_CID, false, nullptr, nsIMEPickerConstructor },
{ &kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor },
{ &kNS_ANDROIDBRIDGE_CID, false, nullptr, nsAndroidBridgeConstructor },
{ nullptr }
};
static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
@ -98,7 +98,7 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{ "@mozilla.org/imepicker;1", &kNS_IMEPICKER_CID },
{ "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
{ "@mozilla.org/android/bridge;1", &kNS_ANDROIDBRIDGE_CID },
{ NULL }
{ nullptr }
};
static void
@ -112,8 +112,8 @@ static const mozilla::Module kWidgetModule = {
mozilla::Module::kVersion,
kWidgetCIDs,
kWidgetContracts,
NULL,
NULL,
nullptr,
nullptr,
nsAppShellInit,
nsWidgetAndroidModuleDtor
};

View File

@ -188,7 +188,7 @@ nsWindow::~nsWindow()
if (mLayerManager == sLayerManager) {
// If this window was the one that created the global OMTC layer manager
// and compositor, then we should null those out.
SetCompositor(NULL, NULL, NULL);
SetCompositor(nullptr, nullptr, nullptr);
}
}
@ -1154,9 +1154,9 @@ void *
nsWindow::GetNativeData(uint32_t aDataType)
{
switch (aDataType) {
// used by GLContextProviderEGL, NULL is EGL_DEFAULT_DISPLAY
// used by GLContextProviderEGL, nullptr is EGL_DEFAULT_DISPLAY
case NS_NATIVE_DISPLAY:
return NULL;
return nullptr;
case NS_NATIVE_WIDGET:
return (void *) this;
@ -1619,7 +1619,7 @@ nsWindow::InitKeyEvent(WidgetKeyboardEvent& event, AndroidGeckoEvent& key,
event.isChar = (charCode >= ' ');
event.charCode = event.isChar ? charCode : 0;
event.keyCode = (event.charCode > 0) ? 0 : domKeyCode;
event.pluginEvent = NULL;
event.pluginEvent = nullptr;
} else {
#ifdef DEBUG
if (event.message != NS_KEY_DOWN && event.message != NS_KEY_UP) {