[macruby-changes] [1715] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jun 3 20:14:39 PDT 2009
Revision: 1715
http://trac.macosforge.org/projects/ruby/changeset/1715
Author: lsansonetti at apple.com
Date: 2009-06-03 20:14:38 -0700 (Wed, 03 Jun 2009)
Log Message:
-----------
make sure we pass the selector to negative arity C methods + some work to support variadic methods/functions dispatch
Modified Paths:
--------------
MacRuby/branches/experimental/array.c
MacRuby/branches/experimental/vm.cpp
Modified: MacRuby/branches/experimental/array.c
===================================================================
--- MacRuby/branches/experimental/array.c 2009-06-04 00:47:51 UTC (rev 1714)
+++ MacRuby/branches/experimental/array.c 2009-06-04 03:14:38 UTC (rev 1715)
@@ -3128,9 +3128,9 @@
VALUE num;
long r, n, i;
- n = RARRAY_LEN(ary); /* Array length */
RETURN_ENUMERATOR(ary, argc, argv); /* Return enumerator if no block */
rb_scan_args(argc, argv, "01", &num);
+ n = RARRAY_LEN(ary); /* Array length */
r = NIL_P(num) ? n : NUM2LONG(num); /* Permutation size from argument */
if (r < 0 || n < r) {
Modified: MacRuby/branches/experimental/vm.cpp
===================================================================
--- MacRuby/branches/experimental/vm.cpp 2009-06-04 00:47:51 UTC (rev 1714)
+++ MacRuby/branches/experimental/vm.cpp 2009-06-04 03:14:38 UTC (rev 1715)
@@ -2113,11 +2113,11 @@
// a negative arity, which means a different calling convention.
if (arity.real == 2) {
return ((VALUE (*)(VALUE, SEL, int, const VALUE *))node->ruby_imp)
- (self, 0, argc, argv);
+ (self, sel, argc, argv);
}
else if (arity.real == 1) {
return ((VALUE (*)(VALUE, SEL, ...))node->ruby_imp)
- (self, 0, rb_ary_new4(argc, argv));
+ (self, sel, rb_ary_new4(argc, argv));
}
else {
printf("invalid negative arity for C function %d\n",
@@ -2155,6 +2155,17 @@
sel_getName(sel));
abort();
}
+ if (ocache.bs_method != NULL && ocache.bs_method->variadic) {
+ const int real_argc = method_getNumberOfArguments(method) - 2;
+ if (real_argc < argc) {
+ const size_t s = strlen(types);
+ assert(s + argc - real_argc < sizeof types);
+ for (int i = real_argc; i < argc; i++) {
+ strlcat(types, "@", sizeof types);
+ }
+ argc = real_argc;
+ }
+ }
ocache.stub = (rb_vm_objc_stub_t *)GET_VM()->gen_stub(types,
argc, true);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090603/29390579/attachment.html>
More information about the macruby-changes
mailing list