From 245b8a0b344dce99e24c13a01da56fd9fafea9b6 Mon Sep 17 00:00:00 2001
From: Vladimir Kalinin
%typemap(ctype) Status "void" %typemap(out, null="") Status { ... }
+The "pre" and "post" attributes in "csdirectorin" typemap act like the same attributes in "csin" typemap. + For example if we modify Date marshalling example like this: +
+class CDate { +... + void setYear(int); + void setMonth(int); + void setDay(int); +}; +struct Action { +virtual void someCallback(CDate& date); +... +}; +
+%typemap(csdirectorin, + pre="System.DateTime temp$iminput = new System.DateTime();", + post="CDate temp2$iminput = new CDate($iminput, false);\n" + "temp2$iminput.setYear(tempdate.Year);\n" + "temp2$iminput.setMonth(tempdate.Month);\n" + "temp2$iminput.setDay(tempdate.Day);" + ) CDate& date "out temp$iminput" +
+... + private void SwigDirectorsomeCallback(IntPtr date) { + System.DateTime tempdate = new System.DateTime(); + try { + someCallback(out tempdate); + } + finally { + // we create managed wrapper around existing C reference, just for convenience + CDate temp2date = new CDate(date, false); + temp2date.setYear(tempdate.Year); + temp2date.setMonth(tempdate.Month); + temp2date.setDay(tempdate.Day); + } + } +... +