[cfe-dev] Rewriting question

Konstantin Tokarev annulen at yandex.ru
Wed Aug 21 02:00:17 PDT 2013



20.08.2013, 20:34, "Vincent R." <forumer at smartmobili.com>:
> Hi,
>
> to be able to rewrite objc code from [myObj someMsg:a withContext:ctx]
> into a java/c# syntax myObj.someMsg_withContext(a, ctx)
> do I need to change the "nature" of the ast node and transforms it from
> an iVar into a c++ object that would have
> a method named someMsg_withContext ?
> IS there any sample code showing how to declare that kind of object ?
> Inside RewriteModernObjC.cpp there is some code to synthetize a C
> function (SynthMsgSendFunctionDecl) but do you have some
> sample code to generate a c++ method it would help I think.

Rewriter works the next way: you visit AST nodes which are interesting for you,
take their SourceRanges's, and use Rewriter methods like ReplaceText or
RemoveText to replace _text_, corresponding to the node, with your _text_,
or remove it, respectively.

So, you change not AST nodes but replace strings inside source whith other strings.

-- 
Regards,
Konstantin



More information about the cfe-dev mailing list