1 /** 2 * This module contains UDA's (User Defined Attributes) either used in 3 * the runtime or special UDA's recognized by compiler. 4 * 5 * Copyright: Copyright Jacob Carlborg 2015. 6 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 * Authors: Jacob Carlborg 8 * Source: $(DRUNTIMESRC core/_attribute.d) 9 */ 10 11 /* Copyright Jacob Carlborg 2015. 12 * Distributed under the Boost Software License, Version 1.0. 13 * (See accompanying file LICENSE or copy at 14 * http://www.boost.org/LICENSE_1_0.txt) 15 */ 16 module core.attribute; 17 18 /** 19 * Use this attribute to attach an Objective-C selector to a method. 20 * 21 * This is a special compiler recognized attribute, it has several 22 * requirements, which all will be enforced by the compiler: 23 * 24 * $(UL 25 * $(LI 26 * The attribute can only be attached to methods or constructors which 27 * have Objective-C linkage. That is, a method or a constructor in a 28 * class or interface declared as $(D_CODE extern(Objective-C)). 29 * ), 30 * 31 * $(LI It cannot be attached to a method or constructor that is a template), 32 * 33 * $(LI 34 * The number of colons in the string need to match the number of 35 * arguments the method accept. 36 * ), 37 * 38 * $(LI It can only be used once in a method declaration) 39 * ) 40 * 41 * Examples: 42 * --- 43 * extern (Objective-C) 44 * class NSObject 45 * { 46 * this() @selector("init"); 47 * static NSObject alloc() @selector("alloc"); 48 * NSObject initWithUTF8String(in char* str) @selector("initWithUTF8String:"); 49 * ObjcObject copyScriptingValue(ObjcObject value, NSString key, NSDictionary properties) 50 * @selector("copyScriptingValue:forKey:withProperties:"); 51 * } 52 * --- 53 */ 54 version (D_ObjectiveC) struct selector 55 { 56 string selector; 57 }