[dmd-internals] open dmd pull requests, oldest Feb 6, 2011
Michel Fortin
michel.fortin at michelf.com
Mon Mar 7 10:38:37 PST 2011
Le 2011-03-07 à 10:14, Benjamin Shropshire a écrit :
> On Mar 6, 2011 3:37 PM, "Michel Fortin" <michel.fortin at michelf.com> wrote:
>>
>> But to give you an idea of what I'm doing inside DMD: I had to change the
>> backend a little so it can emit special Objective-C-reserved segments with
>> custom alignment, I had to change the parser to add a new keyword
>> (__selector) and a syntax for specifying selectors and even to parse the
>> "extern(Objective-C)" construct, I had to make strings literals implicitly
>> convertible to Objective-C's NSString literals and made some other type
>> implicitly convert to equivalents, I had to make 'static' functions virtual
>> functions belonging to the Objective-C metaclass (whether I should have
>> invented a new keyword for that is debatable), I had to create an implicit
>> nested class named "Class" in each class representing the metaclass and to
>> add the built-in property "this.class" to access the metaclass, I had to
>> implement dynamic casts of Objective-C objects, and a few other ticks like
>> that.
>
> Aside from the parser changes, how much of that could be done with keyhole
> overrides (e.g. the name mangleing function and variable/member layout) and
> an extra set of augmentation passes (e.g. adding the nested Class and
> accessor)?
I don't think I could go very far with that. Look at all the files I touched up to now, it should give you an idea:
<https://github.com/michelf/dmd/compare/f8ed1b3...d-objc>
The funny thing is that none of the above is really *required* to manipulate and create Objective-C objects. All you need is extern(C) to interact with the Objective-C runtime and some templates to make things easier and more type-safe. That's what I did with the D/Objective-C bridge. The problem is that it doesn't scale very well when you have large Objective-C APIs.
<http://michelf.com/weblog/2010/dobjc-dead-end-start-anew/>
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the dmd-internals
mailing list