From 7b984f5a1c54dbe2dca310992c60e196337d9f5c Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Tue, 14 Jun 2016 10:29:05 -0400 Subject: Improve the casing macros Make GTM_STATIC_CAST(className, object) and GTM_DYNAMIC_CAST(className, object) return objects that are type-casted to className *, instead of id. This enables access to properties on the casted objects, e.g. GTM_STATIC_CAST(NSString, object).length which wouldn't work previously, since accessing .length on an id type (correctly) results in a compiler error. --- DebugUtils/GTMTypeCasting.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'DebugUtils') diff --git a/DebugUtils/GTMTypeCasting.h b/DebugUtils/GTMTypeCasting.h index f53b3d2..0c5899f 100644 --- a/DebugUtils/GTMTypeCasting.h +++ b/DebugUtils/GTMTypeCasting.h @@ -1,14 +1,14 @@ // // GTMTypeCasting.h -// +// // Copyright 2010 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -58,14 +58,14 @@ GTM_INLINE id GTMStaticCastSupport(Class cls, id object) { #ifndef GTM_STATIC_CAST #ifdef DEBUG - #define GTM_STATIC_CAST(type, object) GTMStaticCastSupport([type class], \ - object) + #define GTM_STATIC_CAST(type, object) \ + ((type *) GTMStaticCastSupport([type class], object)) #else #define GTM_STATIC_CAST(type, object) ((type *) (object)) #endif #endif #ifndef GTM_DYNAMIC_CAST - #define GTM_DYNAMIC_CAST(type, object) GTMDynamicCastSupport([type class], \ - object) + #define GTM_DYNAMIC_CAST(type, object) \ + ((type *) GTMDynamicCastSupport([type class], object)) #endif -- cgit v1.2.3