sharedRuntime same context as MacRuby's runtime
Hi, I am trying to implement some macruby pre-initialisation inside an Objective-C class, to enhance the Objective-C class with some ruby methods before returning the initialized object to MacRuby. I was wondering if the + MacRuby sharedRuntime execution context is the same as my MacRuby application execution context? Right now, it does not seem like the sharedRuntime preparation I do inside my Objective-C initializer does affect my MacRuby execution: in MacRuby: framework "MyObjCFramework" myObject = MyClass.enhancedInitializer in Objective-C: // MyObjCFramework ... + (id)enhancedInitializer { id myInstance = [MyClass regularInitializer]; NSBundle * fbundle = [NSBundle bundleForClass:[MyClass class]]; NSString * rbPath = [fbundle pathForResource:@"myClass_ruby" ofType:@"rb"]; [[MacRuby sharedRuntime] evaluateFileAtPath:rbPath]; return myInstance; } Is something like this supposed to be possible? Thanks! L-P
Has anyone gotten CorePlot working in a MacRuby app? http://code.google.com/p/core-plot/ I'm working on re-writing the DatePlot app in MacRuby and have had limited success, but I'm currently stuck with problems surrounding: CPPlotRange.plotRangeWithLocation and CPDecimalFromFloat Cheers, russ
Can you provide a code snippet (irb) reproducing the exact problem you are experiencing? On Nov 10, 2010, at 5:59 AM, Russ McBride wrote:
Has anyone gotten CorePlot working in a MacRuby app?
http://code.google.com/p/core-plot/
I'm working on re-writing the DatePlot app in MacRuby and have had limited success, but I'm currently stuck with problems surrounding:
CPPlotRange.plotRangeWithLocation
and CPDecimalFromFloat
Cheers, russ
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hmm ... I think I've got some linking/import issues, although the framework is found.
framework 'cocoa' => true framework 'coreplot' => true
graph = CPXYGraph.alloc.initWithFrame(CGRectMake(0,0,0,0)) => #<CPXYGraph:0x20054cb00> plotSpace = graph.defaultPlotSpace; => #<CPXYPlotSpace:0x20051d360> axisSet = graph.axisSet => #<CPXYAxisSet:0x2005229c0>
So good, so far, but...
x = 4.2 => 4.2 x.class => Float z = CPDecimalFromFloat(x) NoMethodError: undefined method `CPDecimalFromFloat' for main:TopLevel
theme = CPTheme.themeNamed(kCPDarkGradientTheme) NameError: undefined local variable or method `kCPDarkGradientTheme' for main:TopLevel CPTheme.method_defined?(:themeNamed) => false
On Nov 10, 2010, at 12:50 AM, Eloy Duran wrote:
Can you provide a code snippet (irb) reproducing the exact problem you are experiencing?
On Nov 10, 2010, at 5:59 AM, Russ McBride wrote:
Has anyone gotten CorePlot working in a MacRuby app?
http://code.google.com/p/core-plot/
I'm working on re-writing the DatePlot app in MacRuby and have had limited success, but I'm currently stuck with problems surrounding:
CPPlotRange.plotRangeWithLocation
and CPDecimalFromFloat
Cheers, russ
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hi Russ, I suspect this CorePlot framework does not include a BridgeSupport file. This could explain why MacRuby cannot use the CPDecimalFromFloat() C function or the kCPDarkGradientTheme C constant (note that it must be called KCPDarkGradientTheme from MacRuby, as constants must always start with a uppercase letter). You can try to generate a BridgeSupport file using gen_bridge_metadata(1). Check out the end of the man page for examples. The generated file should be installed within the framework. Laurent On Nov 10, 2010, at 11:49 AM, Russ McBride wrote:
Hmm ... I think I've got some linking/import issues, although the framework is found.
framework 'cocoa' => true framework 'coreplot' => true
graph = CPXYGraph.alloc.initWithFrame(CGRectMake(0,0,0,0)) => #<CPXYGraph:0x20054cb00> plotSpace = graph.defaultPlotSpace; => #<CPXYPlotSpace:0x20051d360> axisSet = graph.axisSet => #<CPXYAxisSet:0x2005229c0>
So good, so far, but...
x = 4.2 => 4.2 x.class => Float z = CPDecimalFromFloat(x) NoMethodError: undefined method `CPDecimalFromFloat' for main:TopLevel
theme = CPTheme.themeNamed(kCPDarkGradientTheme) NameError: undefined local variable or method `kCPDarkGradientTheme' for main:TopLevel CPTheme.method_defined?(:themeNamed) => false
On Nov 10, 2010, at 12:50 AM, Eloy Duran wrote:
Can you provide a code snippet (irb) reproducing the exact problem you are experiencing?
On Nov 10, 2010, at 5:59 AM, Russ McBride wrote:
Has anyone gotten CorePlot working in a MacRuby app?
http://code.google.com/p/core-plot/
I'm working on re-writing the DatePlot app in MacRuby and have had limited success, but I'm currently stuck with problems surrounding:
CPPlotRange.plotRangeWithLocation
and CPDecimalFromFloat
Cheers, russ
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Merci Laurent. That's progress. I generated a BridgeSupport file. Now, I'm getting this:
theme = CPTheme.themeNamed(KCPDarkGradientTheme) => #<CPDarkGradientTheme:0x200621300>
But now:
z = CPDecimalFromFloat(4.1) Assertion failed: (size > 0), function convert_type, file compiler.cpp, line 5803. Abort trap
CPDecimalFromFloat and friends are not inline functions so I don't need to generate a dylib file, as far as I can tell. And:
xLow = 0.0 => 0.0 xLow = NSNumber.numberWithFloat(xLow.to_f).decimalValue => #<NSDecimal:0x20055fc60> fDays = 398.0 => 398.0 fDays = NSNumber.numberWithFloat(fDays.to_f).decimalValue => #<NSDecimal:0x2005ebe60> xrange = CPPlotRange.plotRangeWithLocation(xLow, length:fDays) Assertion failed: (size > 0), function convert_type, file compiler.cpp, line 5803. Abort trap
Cheers, russ On Nov 10, 2010, at 12:03 PM, Laurent Sansonetti wrote:
Hi Russ,
I suspect this CorePlot framework does not include a BridgeSupport file. This could explain why MacRuby cannot use the CPDecimalFromFloat() C function or the kCPDarkGradientTheme C constant (note that it must be called KCPDarkGradientTheme from MacRuby, as constants must always start with a uppercase letter).
You can try to generate a BridgeSupport file using gen_bridge_metadata(1). Check out the end of the man page for examples. The generated file should be installed within the framework.
Laurent
On Nov 10, 2010, at 11:49 AM, Russ McBride wrote:
Hmm ... I think I've got some linking/import issues, although the framework is found.
framework 'cocoa' => true framework 'coreplot' => true
graph = CPXYGraph.alloc.initWithFrame(CGRectMake(0,0,0,0)) => #<CPXYGraph:0x20054cb00> plotSpace = graph.defaultPlotSpace; => #<CPXYPlotSpace:0x20051d360> axisSet = graph.axisSet => #<CPXYAxisSet:0x2005229c0>
So good, so far, but...
x = 4.2 => 4.2 x.class => Float z = CPDecimalFromFloat(x) NoMethodError: undefined method `CPDecimalFromFloat' for main:TopLevel
theme = CPTheme.themeNamed(kCPDarkGradientTheme) NameError: undefined local variable or method `kCPDarkGradientTheme' for main:TopLevel CPTheme.method_defined?(:themeNamed) => false
On Nov 10, 2010, at 12:50 AM, Eloy Duran wrote:
Can you provide a code snippet (irb) reproducing the exact problem you are experiencing?
On Nov 10, 2010, at 5:59 AM, Russ McBride wrote:
Has anyone gotten CorePlot working in a MacRuby app?
http://code.google.com/p/core-plot/
I'm working on re-writing the DatePlot app in MacRuby and have had limited success, but I'm currently stuck with problems surrounding:
CPPlotRange.plotRangeWithLocation
and CPDecimalFromFloat
Cheers, russ
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hi Russ, Could you try MacRuby trunk? (Try the latest nightly build: http://www.macruby.org/files/nightlies/) I changed the compiler to recognize C-style arrays in structs and I'm believe it's the problem you're hitting. Also, I believe that gen_bridge_metadata will generate 32-bit metadata by default, and I suppose you run MacRuby in 64-bit mode (as it is the default on 64-bit hardware). You may want to pass the --64-bit argument to the generator. Laurent On Nov 10, 2010, at 3:43 PM, Russ McBride wrote:
Merci Laurent. That's progress. I generated a BridgeSupport file.
Now, I'm getting this:
theme = CPTheme.themeNamed(KCPDarkGradientTheme) => #<CPDarkGradientTheme:0x200621300>
But now:
z = CPDecimalFromFloat(4.1) Assertion failed: (size > 0), function convert_type, file compiler.cpp, line 5803. Abort trap
CPDecimalFromFloat and friends are not inline functions so I don't need to generate a dylib file, as far as I can tell.
And:
xLow = 0.0 => 0.0 xLow = NSNumber.numberWithFloat(xLow.to_f).decimalValue => #<NSDecimal:0x20055fc60> fDays = 398.0 => 398.0 fDays = NSNumber.numberWithFloat(fDays.to_f).decimalValue => #<NSDecimal:0x2005ebe60> xrange = CPPlotRange.plotRangeWithLocation(xLow, length:fDays) Assertion failed: (size > 0), function convert_type, file compiler.cpp, line 5803. Abort trap
Cheers, russ
On Nov 10, 2010, at 12:03 PM, Laurent Sansonetti wrote:
Hi Russ,
I suspect this CorePlot framework does not include a BridgeSupport file. This could explain why MacRuby cannot use the CPDecimalFromFloat() C function or the kCPDarkGradientTheme C constant (note that it must be called KCPDarkGradientTheme from MacRuby, as constants must always start with a uppercase letter).
You can try to generate a BridgeSupport file using gen_bridge_metadata(1). Check out the end of the man page for examples. The generated file should be installed within the framework.
Laurent
On Nov 10, 2010, at 11:49 AM, Russ McBride wrote:
Hmm ... I think I've got some linking/import issues, although the framework is found.
framework 'cocoa' => true framework 'coreplot' => true
graph = CPXYGraph.alloc.initWithFrame(CGRectMake(0,0,0,0)) => #<CPXYGraph:0x20054cb00> plotSpace = graph.defaultPlotSpace; => #<CPXYPlotSpace:0x20051d360> axisSet = graph.axisSet => #<CPXYAxisSet:0x2005229c0>
So good, so far, but...
x = 4.2 => 4.2 x.class => Float z = CPDecimalFromFloat(x) NoMethodError: undefined method `CPDecimalFromFloat' for main:TopLevel
theme = CPTheme.themeNamed(kCPDarkGradientTheme) NameError: undefined local variable or method `kCPDarkGradientTheme' for main:TopLevel CPTheme.method_defined?(:themeNamed) => false
On Nov 10, 2010, at 12:50 AM, Eloy Duran wrote:
Can you provide a code snippet (irb) reproducing the exact problem you are experiencing?
On Nov 10, 2010, at 5:59 AM, Russ McBride wrote:
Has anyone gotten CorePlot working in a MacRuby app?
http://code.google.com/p/core-plot/
I'm working on re-writing the DatePlot app in MacRuby and have had limited success, but I'm currently stuck with problems surrounding:
CPPlotRange.plotRangeWithLocation
and CPDecimalFromFloat
Cheers, russ
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
On 11/10/10 4:39 PM, Laurent Sansonetti wrote:
Also, I believe that gen_bridge_metadata will generate 32-bit metadata by default, and I suppose you run MacRuby in 64-bit mode (as it is the default on 64-bit hardware). You may want to pass the --64-bit argument to the generator. That default seems a little backwards, yes? Most of our apps and frameworks are 64 bit now, so why default to 32 bits?
- Jordan
On Nov 10, 2010, at 5:50 PM, Jordan Hubbard wrote:
On 11/10/10 4:39 PM, Laurent Sansonetti wrote:
Also, I believe that gen_bridge_metadata will generate 32-bit metadata by default, and I suppose you run MacRuby in 64-bit mode (as it is the default on 64-bit hardware). You may want to pass the --64-bit argument to the generator. That default seems a little backwards, yes? Most of our apps and frameworks are 64 bit now, so why default to 32 bits?
Agreed. <rdar://problem/8655701>. Laurent
Thanks for the suggestions, Laurent. I re-generated the BridgeSupport version with a 64-bit-specific version, then ran a diff on the old version and new version and the content appears the same. The file is in /Library/Frameworks/CorePlot.framework/Resources/BridgeSupport/CorePlot.bridgesupport And I replaced my MacRuby install with the latest nightly. Now I get this:
framework 'cocoa' => true framework 'coreplot' => true a = 4.2 => 4.2 z = CPDecimalFromFloat(a) TypeError: invalid bitfield type: b
z = CPDecimalFromFloat(a) Segmentation fault
...
xLow = 0.0 => 0.0 xLow = NSNumber.numberWithFloat(xLow.to_f).decimalValue => #<NSDecimal:0x2005bfae0> fDays = 398.0 => 398.0 fDays = NSNumber.numberWithFloat(fDays.to_f).decimalValue => #<NSDecimal:0x2005fbf00> xrange = CPPlotRange.plotRangeWithLocation(xLow, length:fDays) TypeError: invalid bitfield type: b
xrange = CPPlotRange.plotRangeWithLocation(xLow, length:fDays) Segmentation fault
This still works, though:
theme = CPTheme.themeNamed(KCPDarkGradientTheme) => #<CPDarkGradientTheme:0x2005c4560>
On a different topic, I've had great fun writing tools with MacRuby + Selenium to probe some of our web apps here at UC Berkeley for performance numbers. The goal of integrating CorePlot is to provide nice graphs of the results (without having to rely on a WebView + javascript graphing libraries). Cheers, Russ On Nov 10, 2010, at 5:59 PM, Laurent Sansonetti wrote:
On Nov 10, 2010, at 5:50 PM, Jordan Hubbard wrote:
On 11/10/10 4:39 PM, Laurent Sansonetti wrote:
Also, I believe that gen_bridge_metadata will generate 32-bit metadata by default, and I suppose you run MacRuby in 64-bit mode (as it is the default on 64-bit hardware). You may want to pass the --64-bit argument to the generator. That default seems a little backwards, yes? Most of our apps and frameworks are 64 bit now, so why default to 32 bits?
Agreed. <rdar://problem/8655701>.
Laurent _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hi Russ, After a quick look, I suspect a problem with NSDecimal, as both CPDecimalFromFloat and +plotRangeWithLocation:length: use it. However I'm unable to reproduce a similar error just playing with NSDecimal directly in MacRuby. $ ./miniruby -e "framework 'Foundation'; p NSDecimalString(42.decimalValue, nil)" "42" Laurent On Nov 10, 2010, at 6:57 PM, Russ McBride wrote:
Thanks for the suggestions, Laurent.
I re-generated the BridgeSupport version with a 64-bit-specific version, then ran a diff on the old version and new version and the content appears the same. The file is in /Library/Frameworks/CorePlot.framework/Resources/BridgeSupport/CorePlot.bridgesupport
And I replaced my MacRuby install with the latest nightly.
Now I get this:
framework 'cocoa' => true framework 'coreplot' => true a = 4.2 => 4.2 z = CPDecimalFromFloat(a) TypeError: invalid bitfield type: b
z = CPDecimalFromFloat(a) Segmentation fault
...
xLow = 0.0 => 0.0 xLow = NSNumber.numberWithFloat(xLow.to_f).decimalValue => #<NSDecimal:0x2005bfae0> fDays = 398.0 => 398.0 fDays = NSNumber.numberWithFloat(fDays.to_f).decimalValue => #<NSDecimal:0x2005fbf00> xrange = CPPlotRange.plotRangeWithLocation(xLow, length:fDays) TypeError: invalid bitfield type: b
xrange = CPPlotRange.plotRangeWithLocation(xLow, length:fDays) Segmentation fault
This still works, though:
theme = CPTheme.themeNamed(KCPDarkGradientTheme) => #<CPDarkGradientTheme:0x2005c4560>
On a different topic, I've had great fun writing tools with MacRuby + Selenium to probe some of our web apps here at UC Berkeley for performance numbers. The goal of integrating CorePlot is to provide nice graphs of the results (without having to rely on a WebView + javascript graphing libraries).
Cheers, Russ
On Nov 10, 2010, at 5:59 PM, Laurent Sansonetti wrote:
On Nov 10, 2010, at 5:50 PM, Jordan Hubbard wrote:
On 11/10/10 4:39 PM, Laurent Sansonetti wrote:
Also, I believe that gen_bridge_metadata will generate 32-bit metadata by default, and I suppose you run MacRuby in 64-bit mode (as it is the default on 64-bit hardware). You may want to pass the --64-bit argument to the generator. That default seems a little backwards, yes? Most of our apps and frameworks are 64 bit now, so why default to 32 bits?
Agreed. <rdar://problem/8655701>.
Laurent _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
I have restricted Internet access so I can't check the API to verify the method signature but at least I can help with the constant issue. It should read KCPDarkGradientTheme and not kCPDarkGradientTheme. This is because in Ruby all constants have to start by a capital letter. - Matt Sent from my iPhone On Nov 10, 2010, at 13:49, Russ McBride <russ@psyex.com> wrote:
Hmm ... I think I've got some linking/import issues, although the framework is found.
framework 'cocoa' => true framework 'coreplot' => true
graph = CPXYGraph.alloc.initWithFrame(CGRectMake(0,0,0,0)) => #<CPXYGraph:0x20054cb00> plotSpace = graph.defaultPlotSpace; => #<CPXYPlotSpace:0x20051d360> axisSet = graph.axisSet => #<CPXYAxisSet:0x2005229c0>
So good, so far, but...
x = 4.2 => 4.2 x.class => Float z = CPDecimalFromFloat(x) NoMethodError: undefined method `CPDecimalFromFloat' for main:TopLevel
theme = CPTheme.themeNamed(kCPDarkGradientTheme) NameError: undefined local variable or method `kCPDarkGradientTheme' for main:TopLevel CPTheme.method_defined?(:themeNamed) => false
On Nov 10, 2010, at 12:50 AM, Eloy Duran wrote:
Can you provide a code snippet (irb) reproducing the exact problem you are experiencing?
On Nov 10, 2010, at 5:59 AM, Russ McBride wrote:
Has anyone gotten CorePlot working in a MacRuby app?
http://code.google.com/p/core-plot/
I'm working on re-writing the DatePlot app in MacRuby and have had limited success, but I'm currently stuck with problems surrounding:
CPPlotRange.plotRangeWithLocation
and CPDecimalFromFloat
Cheers, russ
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (6)
-
Eloy Duran
-
Jordan Hubbard
-
Laurent Sansonetti
-
Louis-Philippe
-
Matt Aimonetti
-
Russ McBride