Objective-C

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Objective-C

Sean P. DeNigris
Administrator
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
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Objective-C

johnmci
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 <[hidden email]> 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
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
>



--
===========================================================================
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================
_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
Reply | Threaded
Open this post in threaded view
|

Re: Objective-C

Sean P. DeNigris
Administrator
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
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Objective-C

Sean P. DeNigris
Administrator
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
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Objective-C

Sean P. DeNigris
Administrator
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 ObjC.st.

Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Objective-C

Mariano Martinez Peck
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 <[hidden email]> wrote:
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
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners



--
Mariano
http://marianopeck.wordpress.com


_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
Reply | Threaded
Open this post in threaded view
|

Re: Objective-C

Sean P. DeNigris
Administrator
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
Cheers,
Sean