<commit_before>//
//  EXTFinalMethod.h
//  extobjc
//
//  Created by <NAME> on 2011-03-02.
//  Released into the public domain.
//

#import <objc/runtime.h>
#import "metamacros.h"

#if 0
/**
 * Declares \a METHOD, which should be an instance method, in \a class, as being final,
 * unable to be overridden. If \c DEBUG is defined and \c NDEBUG is not defined, any
 * overriding of final methods will abort the application at startup; otherwise, any
 * overriding is simply logged and execution continues using the overriding
 * behavior.
 */
#define finalInstanceMethod(CLASS, METHOD) \
	/*
	 * using the "constructor" function attribute, we can ensure that this
	 * function is executed only AFTER all the Objective-C runtime setup (i.e.,
	 * after all +load methods have been executed)
	 */ \
	__attribute__((constructor)) \
	static void metamacro_concat(ext_checkFinalMethods_, __LINE__) (void) { \
		Class targetClass = objc_getClass(metamacro_stringify(CLASS)); \
		if (!ext_verifyFinalMethod(@selector(METHOD), targetClass)) \
			ext_finalMethodFailed(CLASS, METHOD); \
	}

/**
 * Declares \a METHOD, which should be a class method, in \a class, as being final,
 * unable to be overridden. If \c DEBUG is defined and \c NDEBUG is not defined, any
 * overriding of final methods will abort the application at startup; otherwise, any
 * overriding is simply logged and execution continues using the overriding
 * behavior.
 */
#define finalClassMethod(CLASS, METHOD) \
	/*
	 * using the "constructor" function attribute, we can ensure that this
	 * function is executed only AFTER all the Objective-C runtime setup (i.e.,
	 * after all +load methods have been executed)
	 */ \
	__attribute__((constructor)) \
	static void metamacro_concat(ext_checkFinalMethods_, __LINE__) (void) { \
		Class targetClass = objc_getClass(metamacro_stringify(CLASS)); \
		\
		targetClass = object_getClass(targetClass); \
		if (!ext_verifyFinalMethod(@selector(METHOD), targetClass)) \
			ext_finalMethodFailed(CLASS, METHOD); \
	}
#endif

/**
 * Declares final methods for \a CLASS. Any methods declared in this block
 * cannot be overridden by subclasses. If \c DEBUG is defined and \c NDEBUG is
 * not defined, any overriding of final methods will abort the application at
 * startup; otherwise, the error is logged and execution continues using the
 * overridden method.
 *
 * Final method declarations must be followed by \c @endfinal.
 *
 * @note This macro should only be used in an implementation file.
 */
#define final(CLASS) \
	protocol ext_ ## CLASS ## _FinalMethods; \
	@protocol ext_ ## CLASS ## _FinalMethodsFakeProtocol <ext_ ## CLASS ## _FinalMethods> \
	@end \
	\
	@interface CLASS (FinalMethodsProtocol) <ext_ ## CLASS ## _FinalMethodsFakeProtocol> \
	@end \
	\
	extern Class ext_finalMethodsClass_; \
	extern Protocol *ext_finalMethodsFakeProtocol_; \
	\
	__attribute__((constructor)) \
	static void ext_ ## CLASS ## _prepareFinalMethods (void) { \
		ext_finalMethodsClass_ = objc_getClass(# CLASS); \
		ext_finalMethodsFakeProtocol_ = @protocol(ext_ ## CLASS ## _FinalMethodsFakeProtocol); \
	} \
	\
	@protocol ext_ ## CLASS ## _FinalMethods

#define endfinal \
	end \
	\
	__attribute__((constructor)) \
	static void metamacro_concat(ext_checkFinalMethods_, __LINE__) (void) { \
		Class targetClass = ext_finalMethodsClass_; \
		\
		unsigned listCount = 0; \
		Protocol **protocolList = protocol_copyProtocolList(ext_finalMethodsFakeProtocol_, &listCount); \
		\<commit_msg>Removed disabled code, added documentation comment to @endfinal<commit_after>//
//  EXTFinalMethod.h
//  extobjc
//
//  Created by <NAME>-Summers on 2011-03-02.
//  Released into the public domain.
//

#import <objc/runtime.h>
#import "metamacros.h"

/**
 * Declares final methods for \a CLASS. Any methods declared in this block
 * cannot be overridden by subclasses. If \c DEBUG is defined and \c NDEBUG is
 * not defined, any overriding of final methods will abort the application at
 * startup; otherwise, the error is logged and execution continues using the
 * overridden method.
 *
 * Final method declarations must be followed by \c @endfinal.
 *
 * @note This macro should only be used in an implementation file.
 */
#define final(CLASS) \
	protocol ext_ ## CLASS ## _FinalMethods; \
	@protocol ext_ ## CLASS ## _FinalMethodsFakeProtocol <ext_ ## CLASS ## _FinalMethods> \
	@end \
	\
	@interface CLASS (FinalMethodsProtocol) <ext_ ## CLASS ## _FinalMethodsFakeProtocol> \
	@end \
	\
	extern Class ext_finalMethodsClass_; \
	extern Protocol *ext_finalMethodsFakeProtocol_; \
	\
	__attribute__((constructor)) \
	static void ext_ ## CLASS ## _prepareFinalMethods (void) { \
		ext_finalMethodsClass_ = objc_getClass(# CLASS); \
		ext_finalMethodsFakeProtocol_ = @protocol(ext_ ## CLASS ## _FinalMethodsFakeProtocol); \
	} \
	\
	@protocol ext_ ## CLASS ## _FinalMethods

/**
 * Ends a set of final method declarations. This must be used instead of \c
 * @end.
 *
 * @note This macro should only be used in an implementation file.
 */
#define endfinal \
	end \
	\
	__attribute__((constructor)) \
	static void metamacro_concat(ext_checkFinalMethods_, __LINE__) (void) { \
		Class targetClass = ext_finalMethodsClass_; \
		\
		unsigned listCount = 0; \
		Protocol **protocolList = protocol_copyProtocolList(ext_finalMethodsFakeProtocol_, &listCount); \
		\
{'fraction_non_alphanumeric': 0.10080569608394228, 'fraction_numerical': 0.0035600524639310474, 'mean_word_length': 4.064516129032258, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2341223', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1531, 'n_words': 542}