Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 82 lines (63 sloc) 1.959 kb
9c1d230 committing experimental branch content
Laurent Sansonetti authored
1 #ifndef __OBJC_H_
2 #define __OBJC_H_
3
4 #if defined(__cplusplus)
5 extern "C" {
6 #endif
7
8 #include "bs.h"
9
10 struct rb_objc_method_sig {
11 const char *types;
12 unsigned int argc;
13 };
14
15 bs_element_method_t * rb_bs_find_method(Class klass, SEL sel);
16
c59aa3c working on a new objc dispatch, marked a few methods are always_inline
Laurent Sansonetti authored
17 bool rb_objc_get_types(VALUE recv, Class klass, SEL sel,
18 bs_element_method_t *bs_method, char *buf, size_t buflen);
9c1d230 committing experimental branch content
Laurent Sansonetti authored
19
20 VALUE rb_objc_call(VALUE recv, SEL sel, int argc, VALUE *argv);
21
22 VALUE rb_objc_call2(VALUE recv, VALUE klass, SEL sel, IMP imp,
23 struct rb_objc_method_sig *sig, bs_element_method_t *bs_method, int argc,
24 VALUE *argv);
25
26 void rb_objc_define_kvo_setter(VALUE klass, ID mid);
27 void rb_objc_change_ruby_method_signature(VALUE mod, ID mid, VALUE sig);
28
29 static inline void
30 rb_objc_install_method(Class klass, SEL sel, IMP imp)
31 {
32 Method method, method2;
33
34 method = class_getInstanceMethod(klass, sel);
35 assert(method != NULL);
36
37 method2 = class_getInstanceMethod((Class)RCLASS_SUPER(klass), sel);
38 if (method == method2) {
39 assert(class_addMethod(klass, sel, imp, method_getTypeEncoding(method)));
40 }
41 else {
42 method_setImplementation(method, imp);
43 }
44 }
45
46 static inline void
47 rb_objc_install_method2(Class klass, const char *selname, IMP imp)
48 {
49 rb_objc_install_method(klass, sel_registerName(selname), imp);
50 }
51
52 static inline bool
53 rb_objc_is_kind_of(id object, Class klass)
54 {
55 Class cls;
56 for (cls = *(Class *)object; cls != NULL; cls = class_getSuperclass(cls)) {
57 if (cls == klass) {
58 return true;
59 }
60 }
61 return false;
62 }
63
64 extern void *placeholder_String;
65 extern void *placeholder_Dictionary;
66 extern void *placeholder_Array;
67
68 static inline bool
69 rb_objc_is_placeholder(id obj)
70 {
71 void *klass = *(void **)obj;
72 return klass == placeholder_String || klass == placeholder_Dictionary || klass == placeholder_Array;
73 }
74
75 bool rb_objc_symbolize_address(void *addr, void **start, char *name, size_t name_len);
76
77 #if defined(__cplusplus)
78 }
79 #endif
80
81 #endif /* __OBJC_H_ */
Something went wrong with that request. Please try again.