+static bool isInitFamilyMethod(NSString *name)
+{
+ NSUInteger i = 0;
+
+ // Skip over initial underscores.
+ for (; i < [name length]; ++i) {
+ if ([name characterAtIndex:i] != '_')
+ break;
+ }
+
+ // Match 'init'.
+ NSUInteger initIndex = 0;
+ NSString* init = @"init";
+ for (; i < [name length] && initIndex < [init length]; ++i, ++initIndex) {
+ if ([name characterAtIndex:i] != [init characterAtIndex:initIndex])
+ return false;
+ }
+
+ // We didn't match all of 'init'.
+ if (initIndex < [init length])
+ return false;
+
+ // If we're at the end or the next character is a capital letter then this is an init-family selector.
+ return i == [name length] || [[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[name characterAtIndex:i]];
+}
+
+static bool shouldSkipMethodWithName(NSString *name)
+{
+ // For clients that don't support init-based constructors just copy
+ // over the init method as we would have before.
+ if (!supportsInitMethodConstructors())
+ return false;
+
+ // Skip over init family methods because we handle those specially
+ // for the purposes of hooking up the constructor correctly.
+ return isInitFamilyMethod(name);
+}
+