March 11, 2014 D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
I just wanted to let everyone know that I have implemented D/Objective-C for 64bit. Everything that worked for 32bit should work, except for exceptions, which are not implemented yet. Objective-C on 64bit uses the modern runtime, which is also the same used on iOS. This means D/Objective-C should now be compatible with iOS as well, at least in theory. For those how don't know what D/Objective-C is. It is a language extension to D making it ABI compatible with Objective-C. This means it's possible to use Objective-C classes, methods, protocols (interfaces) and so on, directly just as it's currently possible to do with regular C functions. Here's a recap of what's implemented, both for 32 and 64bit unless otherwise noticed: * Classes * Subclasses * Instance and class methods * Protocols (interfaces) * Properties * Exceptions (only 32bit) * Selectors * Class references * String literals * Casts Some improvements that are really not part of Objective-C but are very convenient to have in D : * Constructors * Inheriting selectors * Automatically generated selectors On the other hand, here a list of what's not implemented yet: * Blocks (similar to delegates) * Categories (class extensions) * Any form of automatic memory management * Exceptions (64bit) * Vtable optimization (64bit) Objective-C exceptions on 64bit is implemented using the same mechanism as C++. I'm wondering if it would be possible for D (not just for this extension) to adapt this mechanism as well. This would make D compatible with both C++ and Objective-C exceptions on 64bit. A DIP is available here [1] and the latest implementation is available here [2]. [1] http://wiki.dlang.org/DIP43 [2] https://github.com/jacob-carlborg/dmd/tree/d-objc -- /Jacob Carlborg |
March 11, 2014 Re: D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On 3/11/14, 11:23 AM, Jacob Carlborg wrote:
> [1] http://wiki.dlang.org/DIP43
> [2] https://github.com/jacob-carlborg/dmd/tree/d-objc
Wow, this is fantastic. Congratulations!
Upon a quick scan, the DIP seems tasteful and well put together. Let's see how to merge this into dmd!
Andrei
|
March 11, 2014 Re: D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Tuesday, 11 March 2014 at 18:23:08 UTC, Jacob Carlborg wrote:
> I just wanted to let everyone know that I have implemented D/Objective-C for 64bit. Everything that worked for 32bit should work, except for exceptions, which are not implemented yet.
>
> Objective-C on 64bit uses the modern runtime, which is also the same used on iOS. This means D/Objective-C should now be compatible with iOS as well, at least in theory.
>
> For those how don't know what D/Objective-C is. It is a language extension to D making it ABI compatible with Objective-C. This means it's possible to use Objective-C classes, methods, protocols (interfaces) and so on, directly just as it's currently possible to do with regular C functions.
>
> Here's a recap of what's implemented, both for 32 and 64bit unless otherwise noticed:
>
> * Classes
> * Subclasses
> * Instance and class methods
> * Protocols (interfaces)
> * Properties
> * Exceptions (only 32bit)
> * Selectors
> * Class references
> * String literals
> * Casts
>
> Some improvements that are really not part of Objective-C but are very convenient to have in D :
>
> * Constructors
> * Inheriting selectors
> * Automatically generated selectors
>
> On the other hand, here a list of what's not implemented yet:
>
> * Blocks (similar to delegates)
> * Categories (class extensions)
> * Any form of automatic memory management
> * Exceptions (64bit)
> * Vtable optimization (64bit)
>
> Objective-C exceptions on 64bit is implemented using the same mechanism as C++. I'm wondering if it would be possible for D (not just for this extension) to adapt this mechanism as well. This would make D compatible with both C++ and Objective-C exceptions on 64bit.
>
> A DIP is available here [1] and the latest implementation is available here [2].
>
> [1] http://wiki.dlang.org/DIP43
> [2] https://github.com/jacob-carlborg/dmd/tree/d-objc
It's really awesome. Congratulations! If this DIP is actually approved will dmd have "native" integration/support to Objective-C language just like we can do with C? I'm not a Obj-C programmer but I like the idea. We could still improve this add new languages
|
March 11, 2014 Re: D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Tuesday, 11 March 2014 at 18:23:08 UTC, Jacob Carlborg wrote: > I just wanted to let everyone know that I have implemented D/Objective-C for 64bit. Everything that worked for 32bit should work, except for exceptions, which are not implemented yet. > <snip> > > A DIP is available here [1] and the latest implementation is available here [2]. > > [1] http://wiki.dlang.org/DIP43 > [2] https://github.com/jacob-carlborg/dmd/tree/d-objc Thanks Jacob, great work! If someone is trying it like me, I don't know the proper way for doing that, but the compiler must be built with the DMD_OBJC define turned on. - Paolo |
March 11, 2014 Re: D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paolo Invernizzi | On Tuesday, 11 March 2014 at 22:13:07 UTC, Paolo Invernizzi wrote:
> If someone is trying it like me, I don't know the proper way for doing that, but the compiler must be built with the DMD_OBJC define turned on.
>
> - Paolo
Sorry, I meant D_OBJC ...
- Paolo
|
March 11, 2014 Re: D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Tuesday, 11 March 2014 at 18:23:08 UTC, Jacob Carlborg wrote:
> I just wanted to let everyone know that I have implemented D/Objective-C for 64bit. Everything that worked for 32bit should work, except for exceptions, which are not implemented yet.
>
> Objective-C on 64bit uses the modern runtime, which is also the same used on iOS. This means D/Objective-C should now be compatible with iOS as well, at least in theory.
>
> For those how don't know what D/Objective-C is. It is a language extension to D making it ABI compatible with Objective-C. This means it's possible to use Objective-C classes, methods, protocols (interfaces) and so on, directly just as it's currently possible to do with regular C functions.
>
> Here's a recap of what's implemented, both for 32 and 64bit unless otherwise noticed:
>
> * Classes
> * Subclasses
> * Instance and class methods
> * Protocols (interfaces)
> * Properties
> * Exceptions (only 32bit)
> * Selectors
> * Class references
> * String literals
> * Casts
>
> Some improvements that are really not part of Objective-C but are very convenient to have in D :
>
> * Constructors
> * Inheriting selectors
> * Automatically generated selectors
>
> On the other hand, here a list of what's not implemented yet:
>
> * Blocks (similar to delegates)
> * Categories (class extensions)
> * Any form of automatic memory management
> * Exceptions (64bit)
> * Vtable optimization (64bit)
>
> Objective-C exceptions on 64bit is implemented using the same mechanism as C++. I'm wondering if it would be possible for D (not just for this extension) to adapt this mechanism as well. This would make D compatible with both C++ and Objective-C exceptions on 64bit.
>
> A DIP is available here [1] and the latest implementation is available here [2].
>
> [1] http://wiki.dlang.org/DIP43
> [2] https://github.com/jacob-carlborg/dmd/tree/d-objc
To what extent will this be portable to ldc/gdc?
|
March 11, 2014 Re: D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On 2014-03-11 18:23:07 +0000, Jacob Carlborg <doob@me.com> said: > I just wanted to let everyone know that I have implemented D/Objective-C for 64bit. Everything that worked for 32bit should work, except for exceptions, which are not implemented yet. It's nice to see you're taking good care of that thing I started. For Objective-C exceptions to work right DMD will have to change its exception model for D exceptions to match the one used by Apple's C++ compiler. It'll make things better for everyone, and no other solution makes much sense really. -- Michel Fortin michel.fortin@michelf.ca http://michelf.ca |
March 11, 2014 Re: D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 2014-03-11 20:28:58 +0000, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> said: > On 3/11/14, 11:23 AM, Jacob Carlborg wrote: >> [1] http://wiki.dlang.org/DIP43 >> [2] https://github.com/jacob-carlborg/dmd/tree/d-objc > > Wow, this is fantastic. Congratulations! > > Upon a quick scan, the DIP seems tasteful and well put together. Let's see how to merge this into dmd! Honestly, I don't think it's ready to be part of the official distribution (no memory management being the worse issue). But it doesn't mean it shouldn't be merged. You need to compile it with the D_OBJC define to get a compiler with Objective-C capabilities, which means that those capabilities don't necessarily need to be part of the official distribution even if the changes are merged. So merge ahead. Also, I'll be glad to participate in the review given I wrote most of that code. -- Michel Fortin michel.fortin@michelf.ca http://michelf.ca |
March 11, 2014 Re: D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin | On 2014-03-11 22:43:58 +0000, "John Colvin" <john.loughran.colvin@gmail.com> said: > To what extent will this be portable to ldc/gdc? The codegen elements in objc.c will need to be changed to bind to the LLVM/GCC backend. Shouldn't be too hard, I guess. [1]: https://github.com/jacob-carlborg/dmd/blob/d-objc/src/objc.c -- Michel Fortin michel.fortin@michelf.ca http://michelf.ca |
March 12, 2014 Re: D/Objective-C 64bit | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michel Fortin | On 3/11/2014 4:18 PM, Michel Fortin wrote:
> Also, I'll be glad to participate in the review given I wrote most of that code.
I'm glad to see this is building on the great groundwork you've already done.
|
Copyright © 1999-2021 by the D Language Foundation