Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed to crash with vargs

  • Loading branch information...
commit 6e0872a95ab6156631e415e4e1615516a2c3484b 1 parent b2b1e50
@masuidrive masuidrive authored
Showing with 9 additions and 2 deletions.
  1. +4 −0 mrblib/object.rb
  2. +5 −2 src/cocoa_object.m
View
4 mrblib/object.rb
@@ -87,6 +87,10 @@ class CFunc::Double
def self.objc_type_encode; 'd'; end
end
+class NilClass
+ def self.objc_type_encode; '@'; end
+end
+
class String
def self.objc_type_encode; '*'; end
def to_ffi_value(ffi_type)
View
7 src/cocoa_object.m
@@ -379,8 +379,11 @@
values = mrb_malloc(mrb, sizeof(void*) * cocoa_argc);
for(i = 0; i < margc; i++) {
mrb_value marg = margs[i];
- if(i > [signature numberOfArguments] - SELF_AND_SEL) {
- arg_types[i+ SELF_AND_SEL] = mrb_value_to_mrb_ffi_type(mrb, marg)->ffi_type_value;
+ if(i >= [signature numberOfArguments] - SELF_AND_SEL) {
+ arg_types[i + SELF_AND_SEL] = mrb_value_to_mrb_ffi_type(mrb, marg)->ffi_type_value;
+ mrb_value args[1];
+ args[0] = mrb_nil_value();
+ marg = mrb_funcall_argv(mrb, marg, sym_to_ffi_value, 1, args);
}
else {
const char *argtype = [signature getArgumentTypeAtIndex:i + SELF_AND_SEL];
Please sign in to comment.
Something went wrong with that request. Please try again.