From f1e548b1e810a7557e8772b67bc181b7743c694f Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Thu, 17 May 2012 15:30:11 +0000 Subject: [Author: levai] Macro for invalidating initializers. R=dmaclach APPROVED=dmaclach DELTA=18 (18 added, 0 deleted, 0 changed) --- GTMDefines.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'GTMDefines.h') diff --git a/GTMDefines.h b/GTMDefines.h index 3936daf..630885c 100644 --- a/GTMDefines.h +++ b/GTMDefines.h @@ -351,6 +351,24 @@ #define GTM_NONNULL(x) __attribute__((nonnull(x))) #endif +// Invalidates the initializer from which it's called. +#ifndef GTMInvalidateInitializer + #if __has_feature(objc_arc) + #define GTMInvalidateInitializer() \ + do { \ + _GTMDevAssert(NO, @"Invalid initializer."); \ + return nil; \ + } while (0) + #else + #define GTMInvalidateInitializer() \ + do { \ + [self release]; \ + _GTMDevAssert(NO, @"Invalid initializer."); \ + return nil; \ + } while (0) + #endif +#endif + #ifdef __OBJC__ // Declared here so that it can easily be used for logging tracking if -- cgit v1.2.3