Projects
Home     Blog     Install     New Ticket     View Tickets     Browse Source

Ticket #109 (closed defect: fixed)

Opened 4 months ago

Last modified 2 months ago

need Objective-C APIs for the runtime

Reported by: tali.wang@… Owned by: lsansonetti@…
Priority: minor Milestone: MacRuby 0.4
Component: MacRuby Keywords:
Cc:

Description

Following codes crash the app.

#import <Cocoa/Cocoa.h> #import <MacRuby/MacRuby.h>

int main(){

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; RUBY_INIT_STACK; ruby_init(); rb_eval_string("puts 1234"); rb_eval_string("puts 34"); rb_eval_string("a=1234"); rb_eval_string("b=a+1234"); rb_eval_string("puts a+b"); [pool release]; return 0;

}

Readout: 1234 34 <dummy toplevel>: [BUG] Bus Error MacRuby version 0.3 (ruby 1.9.0 2008-06-03) [universal-darwin9.4]

-- stack frame ------------ 0000 (0x30030): 00000004 0001 (0x30034): 00000001 <- lfp <- dfp -- control frame ---------- c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP


-- backtrace of native function call (Use addr2line) -- 0x2b5fe6 0x1dee1c 0x1dee5b 0x26ff7b 0x9063509b 0xffffffff 0x1e3c63 0x2ad820 0x2adc81 0x2adfd1 0x1f18 0x1e52


Abort trap

Change History

Changed 4 months ago by lsansonetti@…

  • priority changed from critical to minor
  • summary changed from rb_eval_string does not work properly to need Objective-C APIs for the runtime
  • milestone set to MacRuby 1.0

Initializing MacRuby is a little bit tricky, doing what you pasted is unfortunately not enough.

I plan to introduce an Objective-C API for MacRuby core to easily initialize and use MacRuby from Objective-C, but in the meantime you will have to use the C API.

To initialize MacRuby, you can look at the macruby_main() function, defined in objc.m, and mimic what it does.

Changed 2 months ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from MacRuby 1.0 to MacRuby 0.4

Since r652 MacRuby now exposes a simple Objective-C API to initialize the runtime and evaluate expressions. See the objc.h header file in the header for more information.

Note: See TracTickets for help on using tickets.