Merge pull request #10 from gunyarakun/fix-invalid-return
[cocotron.git] / objc / objc_sel.h
blob5baf22832cd6f9e6cad30acef05d24d93ee731d3
1 /* Copyright (c) 2006-2007 Christopher J. W. Lloyd
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
9 #import <objc/objc.h>
10 #import <objc/objc-class.h>
12 OBJC_EXPORT const char *sel_registerNameNoCopy(const char *name);
14 OBJC_EXPORT SEL sel_registerSelectorNoCopyName(const char *name);
16 #ifdef OBJC_TYPED_SELECTORS
18 typedef struct {
19 const char *name;
20 const char *types;
21 } objc_selector_internal;
23 static inline const char *objc_getSelectorReferenceName(objc_selector_internal *ref) {
24 return ref->name;
27 static inline void objc_setSelectorReferenceName(objc_selector_internal **ref, const char *name) {
28 (*ref)->name = name;
31 static inline SEL sel_getSelector(SEL selector) {
32 if(selector == NULL)
33 return selector;
35 struct {
36 SEL selector;
37 } *typed = (void *)selector;
39 return typed->selector;
42 #else
44 typedef SEL objc_selector_internal;
46 static inline const char *objc_getSelectorReferenceName(objc_selector_internal *ref) {
47 return (const char *)(*ref);
50 static inline void objc_setSelectorReferenceName(objc_selector_internal **ref, const char *name) {
51 **ref = (objc_selector_internal)name;
54 static inline SEL sel_getSelector(SEL selector) {
55 return selector;
58 #endif