Permalink
Browse files

honor bridgesupport metadata when calculating the default objc signat…

…ure of a new method

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4409 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 12e4352 commit 0daff74cd0d470646d1781385d0aa627913354fc @lrz lrz committed Aug 6, 2010
Showing with 43 additions and 21 deletions.
  1. +20 −0 objc.h
  2. +0 −21 objc.m
  3. +23 −0 vm.cpp
View
@@ -15,6 +15,26 @@ extern "C" {
#include "bs.h"
+static inline const char *
+rb_get_bs_method_type(bs_element_method_t *bs_method, int arg)
+{
+ if (bs_method != NULL) {
+ if (arg == -1) {
+ if (bs_method->retval != NULL) {
+ return bs_method->retval->type;
+ }
+ }
+ else {
+ for (unsigned int i = 0; i < bs_method->args_count; i++) {
+ if (bs_method->args[i].index == arg) {
+ return bs_method->args[i].type;
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
bool rb_objc_get_types(VALUE recv, Class klass, SEL sel, Method m,
bs_element_method_t *bs_method, char *buf, size_t buflen);
View
@@ -26,27 +26,6 @@
# include "bs.h"
#endif
-static inline const char *
-rb_get_bs_method_type(bs_element_method_t *bs_method, int arg)
-{
- if (bs_method != NULL) {
- if (arg == -1) {
- if (bs_method->retval != NULL) {
- return bs_method->retval->type;
- }
- }
- else {
- int i;
- for (i = 0; i < bs_method->args_count; i++) {
- if (bs_method->args[i].index == arg) {
- return bs_method->args[i].type;
- }
- }
- }
- }
- return NULL;
-}
-
bool
rb_objc_get_types(VALUE recv, Class klass, SEL sel, Method method,
bs_element_method_t *bs_method, char *buf, size_t buflen)
View
@@ -1664,6 +1664,16 @@ kvo_sel(Class klass, const char *selname, const size_t selsize,
#endif
}
+static const char *
+get_bs_method_type(bs_element_method_t *bs_method, int idx)
+{
+ const char *type = rb_get_bs_method_type(bs_method, idx);
+ if (type == NULL) {
+ type = "@";
+ }
+ return type;
+}
+
static void
resolve_method_type(char *buf, const size_t buflen, Class klass, Method m,
SEL sel, const unsigned int types_count)
@@ -1716,6 +1726,19 @@ resolve_method_type(char *buf, const size_t buflen, Class klass, Method m,
else if (kvo_sel(klass, selname, selsize, "get", ":range:")) {
}
#endif
+ else if (bs_method != NULL) {
+ buf[0] = '\0';
+
+ // retval, self and sel.
+ strlcat(buf, get_bs_method_type(bs_method, -1), buflen);
+ strlcat(buf, "@", buflen);
+ strlcat(buf, ":", buflen);
+
+ // Arguments.
+ for (unsigned int i = 3; i < types_count; i++) {
+ strlcat(buf, get_bs_method_type(bs_method, i - 3), buflen);
+ }
+ }
else {
assert(types_count < buflen);

0 comments on commit 0daff74

Please sign in to comment.