Add new terminator attribute for the csin typemap for C#
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10808 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
907171735f
commit
044895ef6e
4 changed files with 210 additions and 9 deletions
|
|
@ -1,6 +1,18 @@
|
||||||
Version 1.3.37 (in progress)
|
Version 1.3.37 (in progress)
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
|
2008-09-02: wsfulton
|
||||||
|
[C#] Support for 'using' and 'fixed' blocks in the 'csin' typemap is now
|
||||||
|
possible through the use of the pre attribute and the new terminator attribute, eg
|
||||||
|
|
||||||
|
%typemap(csin,
|
||||||
|
pre=" using (CDate temp$csinput = new CDate($csinput)) {",
|
||||||
|
terminator=" } // terminate temp$csinput using block",
|
||||||
|
) const CDate &
|
||||||
|
"$csclassname.getCPtr(temp$csinput)"
|
||||||
|
|
||||||
|
See CSharp.html for more info.
|
||||||
|
|
||||||
2008-09-01: wsfulton
|
2008-09-01: wsfulton
|
||||||
[CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into
|
[CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into
|
||||||
no-eval context in DEFCENUM
|
no-eval context in DEFCENUM
|
||||||
|
|
|
||||||
|
|
@ -1567,6 +1567,7 @@ Let's assume the code being wrapped is as follows:
|
||||||
<pre>
|
<pre>
|
||||||
class CDate {
|
class CDate {
|
||||||
public:
|
public:
|
||||||
|
CDate();
|
||||||
CDate(int year, int month, int day);
|
CDate(int year, int month, int day);
|
||||||
int getYear();
|
int getYear();
|
||||||
int getMonth();
|
int getMonth();
|
||||||
|
|
@ -1649,8 +1650,8 @@ The typemaps to achieve this are shown below.
|
||||||
<pre>
|
<pre>
|
||||||
%typemap(cstype) const CDate& "System.DateTime"
|
%typemap(cstype) const CDate& "System.DateTime"
|
||||||
%typemap(csin,
|
%typemap(csin,
|
||||||
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);")
|
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
|
||||||
const CDate &
|
) const CDate &
|
||||||
"$csclassname.getCPtr(temp$csinput)"
|
"$csclassname.getCPtr(temp$csinput)"
|
||||||
|
|
||||||
%typemap(cstype) CDate& "out System.DateTime"
|
%typemap(cstype) CDate& "out System.DateTime"
|
||||||
|
|
@ -1658,7 +1659,8 @@ The typemaps to achieve this are shown below.
|
||||||
pre=" CDate temp$csinput = new CDate();",
|
pre=" CDate temp$csinput = new CDate();",
|
||||||
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
||||||
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||||
cshin="out $csinput") CDate &
|
cshin="out $csinput"
|
||||||
|
) CDate &
|
||||||
"$csclassname.getCPtr(temp$csinput)"
|
"$csclassname.getCPtr(temp$csinput)"
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
|
|
@ -1763,7 +1765,8 @@ will be possible with the following <tt>CDate *</tt> typemaps
|
||||||
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
|
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
|
||||||
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
||||||
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||||
cshin="ref $csinput") CDate *
|
cshin="ref $csinput"
|
||||||
|
) CDate *
|
||||||
"$csclassname.getCPtr(temp$csinput)"
|
"$csclassname.getCPtr(temp$csinput)"
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1788,6 +1791,50 @@ public class example {
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The following typemap is the same as the previous but demonstrates how a using block can be used for the temporary variable.
|
||||||
|
The only change to the previous typemap is the introduction of the 'terminator' attribute to terminate the <tt>using</tt> block.
|
||||||
|
The <tt>subtractYears</tt> method is nearly identical to the above <tt>addYears</tt> method.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
%typemap(csin,
|
||||||
|
pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
|
||||||
|
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
||||||
|
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||||
|
terminator=" } // terminate temp$csinput using block",
|
||||||
|
cshin="ref $csinput"
|
||||||
|
) CDate *
|
||||||
|
"$csclassname.getCPtr(temp$csinput)"
|
||||||
|
|
||||||
|
void subtractYears(CDate *pDate, int years) {
|
||||||
|
*pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The resulting generated code shows the termination of the <tt>using</tt> block:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="code">
|
||||||
|
<pre>
|
||||||
|
public class example {
|
||||||
|
public static void subtractYears(ref System.DateTime pDate, int years) {
|
||||||
|
using (CDate temppDate = new CDate(pDate.Year, pDate.Month, pDate.Day)) {
|
||||||
|
try {
|
||||||
|
examplePINVOKE.subtractYears(CDate.getCPtr(temppDate), years);
|
||||||
|
} finally {
|
||||||
|
pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(), 0, 0, 0);
|
||||||
|
}
|
||||||
|
} // terminate temppDate using block
|
||||||
|
}
|
||||||
|
...
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
<H3><a name="csharp_date_properties"></a>17.5.4 A date example demonstrating marshalling of C# properties</H3>
|
<H3><a name="csharp_date_properties"></a>17.5.4 A date example demonstrating marshalling of C# properties</H3>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1827,7 +1874,8 @@ The typemap type required is thus <tt>CDate *</tt>. Given that the previous sect
|
||||||
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
|
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
|
||||||
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
||||||
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||||
cshin="ref $csinput") CDate *
|
cshin="ref $csinput"
|
||||||
|
) CDate *
|
||||||
"$csclassname.getCPtr(temp$csinput)"
|
"$csclassname.getCPtr(temp$csinput)"
|
||||||
|
|
||||||
%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{
|
%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
%module csharp_prepost
|
%module csharp_prepost
|
||||||
|
|
||||||
// Test the pre, post and cshin attributes for csin typemaps
|
// Test the pre, post, terminate and cshin attributes for csin typemaps
|
||||||
|
|
||||||
%include "std_vector.i"
|
%include "std_vector.i"
|
||||||
|
|
||||||
|
|
@ -88,3 +88,102 @@ public:
|
||||||
};
|
};
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// test Date marshalling with pre post and terminate typemap attributes (Documented in CSharp.html)
|
||||||
|
%typemap(cstype) const CDate& "System.DateTime"
|
||||||
|
%typemap(csin,
|
||||||
|
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
|
||||||
|
) const CDate &
|
||||||
|
"$csclassname.getCPtr(temp$csinput)"
|
||||||
|
|
||||||
|
%typemap(cstype) CDate& "out System.DateTime"
|
||||||
|
%typemap(csin,
|
||||||
|
pre=" CDate temp$csinput = new CDate();",
|
||||||
|
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
||||||
|
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||||
|
cshin="out $csinput"
|
||||||
|
) CDate &
|
||||||
|
"$csclassname.getCPtr(temp$csinput)"
|
||||||
|
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
class CDate {
|
||||||
|
public:
|
||||||
|
CDate();
|
||||||
|
CDate(int year, int month, int day);
|
||||||
|
int getYear();
|
||||||
|
int getMonth();
|
||||||
|
int getDay();
|
||||||
|
private:
|
||||||
|
int m_year;
|
||||||
|
int m_month;
|
||||||
|
int m_day;
|
||||||
|
};
|
||||||
|
struct Action {
|
||||||
|
int doSomething(const CDate &dateIn, CDate &dateOut);
|
||||||
|
Action(const CDate &dateIn, CDate& dateOut);
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
%{
|
||||||
|
Action::Action(const CDate &dateIn, CDate& dateOut) {dateOut = dateIn;}
|
||||||
|
int Action::doSomething(const CDate &dateIn, CDate &dateOut) { dateOut = dateIn; return 0; }
|
||||||
|
CDate::CDate() : m_year(0), m_month(0), m_day(0) {}
|
||||||
|
CDate::CDate(int year, int month, int day) : m_year(year), m_month(month), m_day(day) {}
|
||||||
|
int CDate::getYear() { return m_year; }
|
||||||
|
int CDate::getMonth() { return m_month; }
|
||||||
|
int CDate::getDay() { return m_day; }
|
||||||
|
%}
|
||||||
|
|
||||||
|
%typemap(cstype, out="System.DateTime") CDate * "ref System.DateTime"
|
||||||
|
|
||||||
|
%typemap(csin,
|
||||||
|
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
|
||||||
|
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
||||||
|
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||||
|
cshin="ref $csinput"
|
||||||
|
) CDate *
|
||||||
|
"$csclassname.getCPtr(temp$csinput)"
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
void addYears(CDate *pDate, int years) {
|
||||||
|
*pDate = CDate(pDate->getYear() + years, pDate->getMonth(), pDate->getDay());
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
|
%typemap(csin,
|
||||||
|
pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
|
||||||
|
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
|
||||||
|
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
|
||||||
|
terminator=" } // terminate temp$csinput using block",
|
||||||
|
cshin="ref $csinput"
|
||||||
|
) CDate *
|
||||||
|
"$csclassname.getCPtr(temp$csinput)"
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
void subtractYears(CDate *pDate, int years) {
|
||||||
|
*pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
|
%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{
|
||||||
|
/* csvarin typemap code */
|
||||||
|
set {
|
||||||
|
CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);
|
||||||
|
$imcall;$excode
|
||||||
|
} %}
|
||||||
|
|
||||||
|
%typemap(csvarout, excode=SWIGEXCODE2) CDate * %{
|
||||||
|
/* csvarout typemap code */
|
||||||
|
get {
|
||||||
|
IntPtr cPtr = $imcall;
|
||||||
|
CDate tempDate = (cPtr == IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode
|
||||||
|
return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(),
|
||||||
|
0, 0, 0);
|
||||||
|
} %}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
CDate ImportantDate = CDate(1999, 12, 31);
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1887,6 +1887,7 @@ public:
|
||||||
bool setter_flag = false;
|
bool setter_flag = false;
|
||||||
String *pre_code = NewString("");
|
String *pre_code = NewString("");
|
||||||
String *post_code = NewString("");
|
String *post_code = NewString("");
|
||||||
|
String *terminator_code = NewString("");
|
||||||
|
|
||||||
if (!proxy_flag)
|
if (!proxy_flag)
|
||||||
return;
|
return;
|
||||||
|
|
@ -2035,6 +2036,14 @@ public:
|
||||||
Printf(post_code, "\n");
|
Printf(post_code, "\n");
|
||||||
Printv(post_code, post, NIL);
|
Printv(post_code, post, NIL);
|
||||||
}
|
}
|
||||||
|
String *terminator = Getattr(p, "tmap:csin:terminator");
|
||||||
|
if (terminator) {
|
||||||
|
substituteClassname(pt, terminator);
|
||||||
|
Replaceall(terminator, "$csinput", arg);
|
||||||
|
if (Len(terminator_code) > 0)
|
||||||
|
Insert(terminator_code, 0, "\n");
|
||||||
|
Insert(terminator_code, 0, terminator);
|
||||||
|
}
|
||||||
Printv(imcall, tm, NIL);
|
Printv(imcall, tm, NIL);
|
||||||
} else {
|
} else {
|
||||||
Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0));
|
Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0));
|
||||||
|
|
@ -2060,7 +2069,8 @@ public:
|
||||||
excodeSubstitute(n, tm, "csout", n);
|
excodeSubstitute(n, tm, "csout", n);
|
||||||
bool is_pre_code = Len(pre_code) > 0;
|
bool is_pre_code = Len(pre_code) > 0;
|
||||||
bool is_post_code = Len(post_code) > 0;
|
bool is_post_code = Len(post_code) > 0;
|
||||||
if (is_pre_code || is_post_code) {
|
bool is_terminator_code = Len(terminator_code) > 0;
|
||||||
|
if (is_pre_code || is_post_code || is_terminator_code) {
|
||||||
Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap
|
Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap
|
||||||
if (is_post_code) {
|
if (is_post_code) {
|
||||||
Insert(tm, 0, "\n try ");
|
Insert(tm, 0, "\n try ");
|
||||||
|
|
@ -2072,6 +2082,9 @@ public:
|
||||||
Insert(tm, 0, pre_code);
|
Insert(tm, 0, pre_code);
|
||||||
Insert(tm, 0, "\n");
|
Insert(tm, 0, "\n");
|
||||||
}
|
}
|
||||||
|
if (is_terminator_code) {
|
||||||
|
Printv(tm, "\n", terminator_code, NIL);
|
||||||
|
}
|
||||||
Insert(tm, 0, "{");
|
Insert(tm, 0, "{");
|
||||||
Printf(tm, "\n }");
|
Printf(tm, "\n }");
|
||||||
}
|
}
|
||||||
|
|
@ -2171,6 +2184,7 @@ public:
|
||||||
|
|
||||||
Delete(pre_code);
|
Delete(pre_code);
|
||||||
Delete(post_code);
|
Delete(post_code);
|
||||||
|
Delete(terminator_code);
|
||||||
Delete(function_code);
|
Delete(function_code);
|
||||||
Delete(return_type);
|
Delete(return_type);
|
||||||
Delete(imcall);
|
Delete(imcall);
|
||||||
|
|
@ -2191,6 +2205,7 @@ public:
|
||||||
String *helper_args = NewString("");
|
String *helper_args = NewString("");
|
||||||
String *pre_code = NewString("");
|
String *pre_code = NewString("");
|
||||||
String *post_code = NewString("");
|
String *post_code = NewString("");
|
||||||
|
String *terminator_code = NewString("");
|
||||||
String *im_return_type = NewString("");
|
String *im_return_type = NewString("");
|
||||||
bool feature_director = (parentNode(n) && Swig_directorclass(n));
|
bool feature_director = (parentNode(n) && Swig_directorclass(n));
|
||||||
|
|
||||||
|
|
@ -2286,6 +2301,14 @@ public:
|
||||||
Printf(post_code, "\n");
|
Printf(post_code, "\n");
|
||||||
Printv(post_code, post, NIL);
|
Printv(post_code, post, NIL);
|
||||||
}
|
}
|
||||||
|
String *terminator = Getattr(p, "tmap:csin:terminator");
|
||||||
|
if (terminator) {
|
||||||
|
substituteClassname(pt, terminator);
|
||||||
|
Replaceall(terminator, "$csinput", arg);
|
||||||
|
if (Len(terminator_code) > 0)
|
||||||
|
Insert(terminator_code, 0, "\n");
|
||||||
|
Insert(terminator_code, 0, terminator);
|
||||||
|
}
|
||||||
cshin = Getattr(p, "tmap:csin:cshin");
|
cshin = Getattr(p, "tmap:csin:cshin");
|
||||||
if (cshin)
|
if (cshin)
|
||||||
Replaceall(cshin, "$csinput", arg);
|
Replaceall(cshin, "$csinput", arg);
|
||||||
|
|
@ -2342,7 +2365,8 @@ public:
|
||||||
|
|
||||||
bool is_pre_code = Len(pre_code) > 0;
|
bool is_pre_code = Len(pre_code) > 0;
|
||||||
bool is_post_code = Len(post_code) > 0;
|
bool is_post_code = Len(post_code) > 0;
|
||||||
if (is_pre_code || is_post_code) {
|
bool is_terminator_code = Len(terminator_code) > 0;
|
||||||
|
if (is_pre_code || is_post_code || is_terminator_code) {
|
||||||
Printf(helper_code, " {\n");
|
Printf(helper_code, " {\n");
|
||||||
if (is_pre_code) {
|
if (is_pre_code) {
|
||||||
Printv(helper_code, pre_code, "\n", NIL);
|
Printv(helper_code, pre_code, "\n", NIL);
|
||||||
|
|
@ -2354,6 +2378,9 @@ public:
|
||||||
} else {
|
} else {
|
||||||
Printv(helper_code, " return ", imcall, ";", NIL);
|
Printv(helper_code, " return ", imcall, ";", NIL);
|
||||||
}
|
}
|
||||||
|
if (is_terminator_code) {
|
||||||
|
Printv(helper_code, "\n", terminator_code, NIL);
|
||||||
|
}
|
||||||
Printf(helper_code, "\n }\n");
|
Printf(helper_code, "\n }\n");
|
||||||
String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args);
|
String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args);
|
||||||
String *im_outattributes = Getattr(n, "tmap:imtype:outattributes");
|
String *im_outattributes = Getattr(n, "tmap:imtype:outattributes");
|
||||||
|
|
@ -2372,6 +2399,7 @@ public:
|
||||||
Delete(im_return_type);
|
Delete(im_return_type);
|
||||||
Delete(pre_code);
|
Delete(pre_code);
|
||||||
Delete(post_code);
|
Delete(post_code);
|
||||||
|
Delete(terminator_code);
|
||||||
Delete(construct_tm);
|
Delete(construct_tm);
|
||||||
Delete(attributes);
|
Delete(attributes);
|
||||||
Delete(overloaded_name);
|
Delete(overloaded_name);
|
||||||
|
|
@ -2489,6 +2517,7 @@ public:
|
||||||
bool setter_flag = false;
|
bool setter_flag = false;
|
||||||
String *pre_code = NewString("");
|
String *pre_code = NewString("");
|
||||||
String *post_code = NewString("");
|
String *post_code = NewString("");
|
||||||
|
String *terminator_code = NewString("");
|
||||||
|
|
||||||
if (l) {
|
if (l) {
|
||||||
if (SwigType_type(Getattr(l, "type")) == T_VOID) {
|
if (SwigType_type(Getattr(l, "type")) == T_VOID) {
|
||||||
|
|
@ -2593,6 +2622,14 @@ public:
|
||||||
Printf(post_code, "\n");
|
Printf(post_code, "\n");
|
||||||
Printv(post_code, post, NIL);
|
Printv(post_code, post, NIL);
|
||||||
}
|
}
|
||||||
|
String *terminator = Getattr(p, "tmap:csin:terminator");
|
||||||
|
if (terminator) {
|
||||||
|
substituteClassname(pt, terminator);
|
||||||
|
Replaceall(terminator, "$csinput", arg);
|
||||||
|
if (Len(terminator_code) > 0)
|
||||||
|
Insert(terminator_code, 0, "\n");
|
||||||
|
Insert(terminator_code, 0, terminator);
|
||||||
|
}
|
||||||
Printv(imcall, tm, NIL);
|
Printv(imcall, tm, NIL);
|
||||||
} else {
|
} else {
|
||||||
Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0));
|
Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0));
|
||||||
|
|
@ -2617,7 +2654,8 @@ public:
|
||||||
excodeSubstitute(n, tm, "csout", n);
|
excodeSubstitute(n, tm, "csout", n);
|
||||||
bool is_pre_code = Len(pre_code) > 0;
|
bool is_pre_code = Len(pre_code) > 0;
|
||||||
bool is_post_code = Len(post_code) > 0;
|
bool is_post_code = Len(post_code) > 0;
|
||||||
if (is_pre_code || is_post_code) {
|
bool is_terminator_code = Len(terminator_code) > 0;
|
||||||
|
if (is_pre_code || is_post_code || is_terminator_code) {
|
||||||
Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap
|
Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap
|
||||||
if (is_post_code) {
|
if (is_post_code) {
|
||||||
Insert(tm, 0, "\n try ");
|
Insert(tm, 0, "\n try ");
|
||||||
|
|
@ -2629,6 +2667,9 @@ public:
|
||||||
Insert(tm, 0, pre_code);
|
Insert(tm, 0, pre_code);
|
||||||
Insert(tm, 0, "\n");
|
Insert(tm, 0, "\n");
|
||||||
}
|
}
|
||||||
|
if (is_terminator_code) {
|
||||||
|
Printv(tm, "\n", terminator_code, NIL);
|
||||||
|
}
|
||||||
Insert(tm, 0, "{");
|
Insert(tm, 0, "{");
|
||||||
Printf(tm, "\n }");
|
Printf(tm, "\n }");
|
||||||
}
|
}
|
||||||
|
|
@ -2704,6 +2745,7 @@ public:
|
||||||
|
|
||||||
Delete(pre_code);
|
Delete(pre_code);
|
||||||
Delete(post_code);
|
Delete(post_code);
|
||||||
|
Delete(terminator_code);
|
||||||
Delete(function_code);
|
Delete(function_code);
|
||||||
Delete(return_type);
|
Delete(return_type);
|
||||||
Delete(imcall);
|
Delete(imcall);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue