[cfe-dev] Source to source transformation : objc to c#

jahanian fjahanian at apple.com
Sat Jul 13 10:34:54 PDT 2013


On Jul 13, 2013, at 4:57 AM, Vincent R. <forumer at smartmobili.com> wrote:

> Le 13.07.2013 02:13, jahanian a écrit :
>> Yes, it is doable. We already have a translation tool to rewrite
>> Objective-C into c++.
>> See Frontend/RewriteModernObjC.cpp as an example of how it i done.
>> This tool has a limitation and a drawback. It only works on
>> pre-processed files.
>> Also, coding style in this tool is dated.
>> 
> 
> 
> and let's consider the following code :
> 
> /**<p>Returns whether the button cell is transparent.</p>
>   <p>See Also: -setTransparent:</p>
> */
> - (BOOL) isTransparent
> {
>  return _buttoncell_is_transparent;
> }
> 
> /**<p>Sets whether the button cell is transparent.</p>
>   <p>See Also: -isTransparent </p>
> */
> - (void) setTransparent: (BOOL)flag
> {
>  _buttoncell_is_transparent = flag;
> }
> 
> 
> once transformed will it be possible to keep comments ?

Note that this specific translator works on the pre-processed file.  If pre-processed files keep 
the comment, this should not be a problem.

> Actually since clang is transforming the source code into an AST I am wondering if clang is not
> too heavy for my task and will generate some ugly code.

In the case of Objective-C translator, this tool makes minimal use  of AST. It uses the AST in only
situations where a translation is needed (for ObjC methods). It produces a new AST and uses the rewriter to
replace the old piece of code with the new one. But, ObjC rewriter task is much easier than what you want because
it is writing into c++ code for which both AST and the rewriter library work. For C# this may not be as simple.
- fariborz


- 





More information about the cfe-dev mailing list