How do I call objective-C code from Squeak/Pharo?
The following tests were done with the Squeak 4.2.5beta1U VM...
I loaded the "Objective-C bridge 2" project from SqS, and about half the tests passed in Pharo 1.1.1. Evaluating: bundle := ObjectiveCBridge classObjectForName: 'NSBundle'. "also tried ObjectiveCObject>>findClassName:" aBundle := bundle bundleWithPath: '/Applications/Mail.app'.
Led to a primitive failure: primitivePerformSelector: aSelectorOop on: aClassorInstanceOop with: argument1 <primitive: 'primitivePerformSelectorWith' module: 'ObjectiveCPlugin'> self primitiveFailed
I tried the "ObjectiveCBridge" project in Squeak 4.2 final... Evaluating: bundle := NSBundle bundleWithPath: '/Applications/Mail.app'.
Led to a different primitive failure: primitiveIdFromString: aString <primitive: 'primitiveIdFromString' module: 'ObjectiveCPlugin'> ^self primitiveFailed
Thanks. Sean-- View this message in context: http://forum.world.st/Objective-C-tp3487777p3487777.html Sent from the Smalltalk VM - Beginners mailing list archive at Nabble.com.
I'd say you are missing the ObjectiveCPlugin.bundle, all the tests should pass as it's a sanity check.
On Sun, May 1, 2011 at 9:53 AM, Sean P. DeNigris sean@clipperadams.com wrote:
How do I call objective-C code from Squeak/Pharo?
The following tests were done with the Squeak 4.2.5beta1U VM...
I loaded the "Objective-C bridge 2" project from SqS, and about half the tests passed in Pharo 1.1.1. Evaluating: bundle := ObjectiveCBridge classObjectForName: 'NSBundle'. "also tried ObjectiveCObject>>findClassName:" aBundle := bundle bundleWithPath: '/Applications/Mail.app'.
Led to a primitive failure: primitivePerformSelector: aSelectorOop on: aClassorInstanceOop with: argument1 <primitive: 'primitivePerformSelectorWith' module: 'ObjectiveCPlugin'> self primitiveFailed
I tried the "ObjectiveCBridge" project in Squeak 4.2 final... Evaluating: bundle := NSBundle bundleWithPath: '/Applications/Mail.app'.
Led to a different primitive failure: primitiveIdFromString: aString <primitive: 'primitiveIdFromString' module: 'ObjectiveCPlugin'> ^self primitiveFailed
Thanks. Sean-- View this message in context: http://forum.world.st/Objective-C-tp3487777p3487777.html Sent from the Smalltalk VM - Beginners mailing list archive at Nabble.com. _______________________________________________ VM-beginners mailing list VM-beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
John McIntosh wrote:
I'd say you are missing the ObjectiveCPlugin.bundle
In Pharo 1.1.1 with the following packages installed: ObjectiveC-Base ObjectiveC-Classes ObjectiveC-Test
I got the following results: * Squeak 4.2.5beta1U (freshly downloaded) with ObjectiveCPlugin.bundle: '29 run, 13 passed, 12 failures, 4 errors' * Squeak 5.7.4.1.app (freshly downloaded) - without ObjectiveCPlugin.bundle: '29 run, 25 passed, 0 failures, 4 errors' - with ObjectiveCPlugin.bundle copied from 4.2.5: '29 run, 13 passed, 12 failures, 4 errors'
All combinations have primitive failure on: bundle := ObjectiveCObject findClassName: 'NSBundle'. aBundle := bundle bundleWithPath: '/Applications/Mail.app'.
Sanity check - works in MacRuby: NSBundle.bundleWithPath('/Applications/Mail.app')
Sean-- View this message in context: http://forum.world.st/Objective-C-tp3487777p3488885.html Sent from the Smalltalk VM - Beginners mailing list archive at Nabble.com.
Thanks to John for pointing out that an NSString must be passed to bundleWithPath:
The following works with the Squeak 5.7.4.1.app VM: bundle := ObjectiveCObject findClassName: 'NSBundle'. nsStringClass := ObjectiveCBridge classObjectForName: 'NSString'. string := '/Applications/Mail.app'. nsString := nsStringClass alloc initWithBytes: string length: string size encoding: 4. aBundle := bundle bundleWithPath: nsString.
Sean-- View this message in context: http://forum.world.st/Objective-C-tp3487777p3489034.html Sent from the Smalltalk VM - Beginners mailing list archive at Nabble.com.
I wrote a simple little class called ObjC to use like a namespace for ObjC classes.
bundle := ObjectiveCObject findClassName: 'NSBundle'. aBundle := bundle bundleWithPath: '/Applications/Mail.app' asNSStringUTF8.
becomes:
ObjC NSBundle bundleWithPath: '/Applications/Mail.app' asNSStringUTF8.
Until (if) it is included in the project, here is the http://forum.world.st/file/n3489140/ObjC.st ObjC.st .
Sean-- View this message in context: http://forum.world.st/Objective-C-tp3487777p3489140.html Sent from the Smalltalk VM - Beginners mailing list archive at Nabble.com.
Cool Sean! do you know if the bridge is still working with Cog VMs? did you try?
thanks
mariano
On Mon, May 2, 2011 at 3:54 AM, Sean P. DeNigris sean@clipperadams.comwrote:
I wrote a simple little class called ObjC to use like a namespace for ObjC classes.
bundle := ObjectiveCObject findClassName: 'NSBundle'. aBundle := bundle bundleWithPath: '/Applications/Mail.app' asNSStringUTF8.
becomes:
ObjC NSBundle bundleWithPath: '/Applications/Mail.app' asNSStringUTF8.
Until (if) it is included in the project, here is the http://forum.world.st/file/n3489140/ObjC.st ObjC.st .
Sean-- View this message in context: http://forum.world.st/Objective-C-tp3487777p3489140.html Sent from the Smalltalk VM - Beginners mailing list archive at Nabble.com. _______________________________________________ VM-beginners mailing list VM-beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
Mariano Martinez Peck wrote:
do you know if the bridge is still working with Cog VMs?
I downloaded one from http://www.mirandabanda.org/files/Cog/VM/VM.r2382/
Executing:
nsBundle := ObjectiveCObject findClassName: 'NSBundle'.
resulted in a primitive failure.
Sean
-- View this message in context: http://forum.world.st/Objective-C-tp3487777p3489833.html Sent from the Smalltalk VM - Beginners mailing list archive at Nabble.com.
vm-beginners@lists.squeakfoundation.org