Hey guys, I've worked out a preliminary patch to support MSVC __declspec(property), based on 3.2RC2.<br clear="all"><div>Patch and a simple test cpp file attached. Please compile the test case with -fms-extensions.</div>
<div><br></div><div>Current status:</div>- Support getter/setter<div>- Support template (see attached test file)</div><div>- No support for +=, -=, etc</div><div>- No support for implicit type conversion for arguments of getter/setter functions</div>
<div><br></div><div>Brief introduction on implementation:</div><div>1. Let Parser parse property declaration.</div><div>2. Add a "PropertyAttr" class to store getter/putter function names.</div><div>3. Notice that there can be "[]" after property declaration, and number of "[]" indicates number of args for getter/setter function(see attached test file). Add a field to QualType to store number of "[]". I know it's horrible, but for a working prototype, that's enough.</div>
<div>4. Add a "MSPropertyExpr". When we encounter property usage in Parser, we don't know whether it's get or set. So we have to add an action AFTER Sema, or do it in CodeGen. Either way, while parsing, all we know is arguments for getter/setter.</div>
<div>5. In CodeGen, deal with "MSPropertyExpr". If it's "scalar" in CodeGen, it's a get, replace it with a CallExpr to getter. If it's "LValue" on the left side of an assignment, replace the whole assignment with a CallExpr to setter.</div>
<div><br></div><div>I know the timing is really bad..</div><div>But, any comments?</div><div><br></div>-- <br>Best Regards, Tong Shen (沈彤)<br>