From: <ta...@us...> - 2008-09-03 05:18:48
|
Revision: 10811 http://swig.svn.sourceforge.net/swig/?rev=10811&view=rev Author: talby Date: 2008-09-03 05:18:44 +0000 (Wed, 03 Sep 2008) Log Message: ----------- trunk sync Modified Paths: -------------- branches/talby-perl5-improvements/CHANGES.current branches/talby-perl5-improvements/Doc/Manual/CSharp.html branches/talby-perl5-improvements/Examples/ruby/std_vector/runme.rb branches/talby-perl5-improvements/Examples/test-suite/csharp_prepost.i branches/talby-perl5-improvements/Lib/csharp/std_vector.i branches/talby-perl5-improvements/Lib/perl5/noembed.h branches/talby-perl5-improvements/Lib/python/director.swg branches/talby-perl5-improvements/Lib/r/r.swg branches/talby-perl5-improvements/Source/Modules/cffi.cxx branches/talby-perl5-improvements/Source/Modules/csharp.cxx branches/talby-perl5-improvements/Source/Modules/uffi.cxx branches/talby-perl5-improvements/configure.in Property Changed: ---------------- branches/talby-perl5-improvements/ Property changes on: branches/talby-perl5-improvements ___________________________________________________________________ Modified: svnmerge-integrated - /trunk:1-10794 + /trunk:1-10810 Modified: branches/talby-perl5-improvements/CHANGES.current =================================================================== --- branches/talby-perl5-improvements/CHANGES.current 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/CHANGES.current 2008-09-03 05:18:44 UTC (rev 10811) @@ -1,9 +1,30 @@ Version 1.3.37 (in progress) ============================= -2008-08-09: talby - [Perl5] Unify Perl and C portions of constructor wrappers. +2008-09-02: wsfulton + [Python] Commit patch #1988296 GCItem multiple module linking issue when using + directors. +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 + [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into + no-eval context in DEFCENUM + +2008-09-01: wsfulton + [C#] Correct array bounds checking in std::vector typemaps - Insert and InsertRange + methods. + 2008-08-02: wuzzeb [Chicken,Allegro] Commit Patch 2019314 Fixes a build error in chicken, and several build errors and other errors Modified: branches/talby-perl5-improvements/Doc/Manual/CSharp.html =================================================================== --- branches/talby-perl5-improvements/Doc/Manual/CSharp.html 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/Doc/Manual/CSharp.html 2008-09-03 05:18:44 UTC (rev 10811) @@ -1567,6 +1567,7 @@ <pre> class CDate { public: + CDate(); CDate(int year, int month, int day); int getYear(); int getMonth(); @@ -1649,8 +1650,8 @@ <pre> %typemap(cstype) const CDate& "System.DateTime" %typemap(csin, - pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);") - const CDate & + pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);" + ) const CDate & "$csclassname.getCPtr(temp$csinput)" %typemap(cstype) CDate& "out System.DateTime" @@ -1658,7 +1659,8 @@ 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 & + cshin="out $csinput" + ) CDate & "$csclassname.getCPtr(temp$csinput)" </pre> @@ -1763,7 +1765,8 @@ 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 * + cshin="ref $csinput" + ) CDate * "$csclassname.getCPtr(temp$csinput)" </pre> </div> @@ -1788,6 +1791,50 @@ </pre> </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> @@ -1827,7 +1874,8 @@ 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 * + cshin="ref $csinput" + ) CDate * "$csclassname.getCPtr(temp$csinput)" %typemap(csvarin, excode=SWIGEXCODE2) CDate * %{ Modified: branches/talby-perl5-improvements/Examples/ruby/std_vector/runme.rb =================================================================== --- branches/talby-perl5-improvements/Examples/ruby/std_vector/runme.rb 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/Examples/ruby/std_vector/runme.rb 2008-09-03 05:18:44 UTC (rev 10811) @@ -9,7 +9,7 @@ # ... or a wrapped std::vector<int> v = Example::IntVector.new(4) -0.upto(v.length-1) { |i| v[i] = i+1 } +0.upto(v.size-1) { |i| v[i] = i+1 } puts Example::average(v) @@ -17,7 +17,7 @@ # Call it with a Ruby array... w = Example::half([1.0, 1.5, 2.0, 2.5, 3.0]) -0.upto(w.length-1) { |i| print w[i],"; " } +0.upto(w.size-1) { |i| print w[i],"; " } puts # ... or a wrapped std::vector<double> @@ -25,12 +25,12 @@ v = Example::DoubleVector.new [1,2,3,4].each { |i| v.push(i) } w = Example::half(v) -0.upto(w.length-1) { |i| print w[i],"; " } +0.upto(w.size-1) { |i| print w[i],"; " } puts # now halve a wrapped std::vector<double> in place Example::halve_in_place(v) -0.upto(v.length-1) { |i| print v[i],"; " } +0.upto(v.size-1) { |i| print v[i],"; " } puts Modified: branches/talby-perl5-improvements/Examples/test-suite/csharp_prepost.i =================================================================== --- branches/talby-perl5-improvements/Examples/test-suite/csharp_prepost.i 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/Examples/test-suite/csharp_prepost.i 2008-09-03 05:18:44 UTC (rev 10811) @@ -1,6 +1,6 @@ %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" @@ -88,3 +88,102 @@ }; %} + + +// 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); +%} + Modified: branches/talby-perl5-improvements/Lib/csharp/std_vector.i =================================================================== --- branches/talby-perl5-improvements/Lib/csharp/std_vector.i 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/Lib/csharp/std_vector.i 2008-09-03 05:18:44 UTC (rev 10811) @@ -231,14 +231,14 @@ return new std::vector<CTYPE >(self->begin()+index, self->begin()+index+count); } void Insert(int index, const value_type& x) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()+1) + if (index>=0 && index<(int)self->size()) self->insert(self->begin()+index, x); else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.InsertRange void InsertRange(int index, const std::vector<CTYPE >& values) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()+1) + if (index>=0 && index<(int)self->size()) self->insert(self->begin()+index, values.begin(), values.end()); else throw std::out_of_range("index"); Modified: branches/talby-perl5-improvements/Lib/perl5/noembed.h =================================================================== --- branches/talby-perl5-improvements/Lib/perl5/noembed.h 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/Lib/perl5/noembed.h 2008-09-03 05:18:44 UTC (rev 10811) @@ -91,3 +91,7 @@ #ifdef open #undef open #endif +#ifdef readdir + #undef readdir +#endif + Modified: branches/talby-perl5-improvements/Lib/python/director.swg =================================================================== --- branches/talby-perl5-improvements/Lib/python/director.swg 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/Lib/python/director.swg 2008-09-03 05:18:44 UTC (rev 10811) @@ -107,7 +107,7 @@ /* memory handler */ struct GCItem { - virtual ~GCItem() = 0; + virtual ~GCItem() {} virtual int get_own() const { @@ -115,10 +115,6 @@ } }; - GCItem::~GCItem() - { - } - struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) Modified: branches/talby-perl5-improvements/Lib/r/r.swg =================================================================== --- branches/talby-perl5-improvements/Lib/r/r.swg 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/Lib/r/r.swg 2008-09-03 05:18:44 UTC (rev 10811) @@ -79,7 +79,7 @@ %typemap(scheck) int %{ if(length($input) > 1) { - Rf_warning("using only the first element of $input") + warning("using only the first element of $input") } %} Modified: branches/talby-perl5-improvements/Source/Modules/cffi.cxx =================================================================== --- branches/talby-perl5-improvements/Source/Modules/cffi.cxx 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/Source/Modules/cffi.cxx 2008-09-03 05:18:44 UTC (rev 10811) @@ -630,7 +630,7 @@ else { String *type = Getattr(c, "type"); String *converted_value = convert_literal(value, type); - Printf(f_cl, "\n\t(%s %s)", slot_name, converted_value); + Printf(f_cl, "\n\t(%s #.%s)", slot_name, converted_value); Delete(converted_value); } Delete(value); Modified: branches/talby-perl5-improvements/Source/Modules/csharp.cxx =================================================================== --- branches/talby-perl5-improvements/Source/Modules/csharp.cxx 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/Source/Modules/csharp.cxx 2008-09-03 05:18:44 UTC (rev 10811) @@ -1887,6 +1887,7 @@ bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); + String *terminator_code = NewString(""); if (!proxy_flag) return; @@ -2035,6 +2036,14 @@ Printf(post_code, "\n"); 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); } else { 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 @@ excodeSubstitute(n, tm, "csout", n); bool is_pre_code = Len(pre_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 if (is_post_code) { Insert(tm, 0, "\n try "); @@ -2072,6 +2082,9 @@ Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } + if (is_terminator_code) { + Printv(tm, "\n", terminator_code, NIL); + } Insert(tm, 0, "{"); Printf(tm, "\n }"); } @@ -2171,6 +2184,7 @@ Delete(pre_code); Delete(post_code); + Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); @@ -2191,6 +2205,7 @@ String *helper_args = NewString(""); String *pre_code = NewString(""); String *post_code = NewString(""); + String *terminator_code = NewString(""); String *im_return_type = NewString(""); bool feature_director = (parentNode(n) && Swig_directorclass(n)); @@ -2286,6 +2301,14 @@ Printf(post_code, "\n"); 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"); if (cshin) Replaceall(cshin, "$csinput", arg); @@ -2342,7 +2365,8 @@ bool is_pre_code = Len(pre_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"); if (is_pre_code) { Printv(helper_code, pre_code, "\n", NIL); @@ -2354,6 +2378,9 @@ } else { Printv(helper_code, " return ", imcall, ";", NIL); } + if (is_terminator_code) { + Printv(helper_code, "\n", terminator_code, NIL); + } Printf(helper_code, "\n }\n"); String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args); String *im_outattributes = Getattr(n, "tmap:imtype:outattributes"); @@ -2372,6 +2399,7 @@ Delete(im_return_type); Delete(pre_code); Delete(post_code); + Delete(terminator_code); Delete(construct_tm); Delete(attributes); Delete(overloaded_name); @@ -2489,6 +2517,7 @@ bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); + String *terminator_code = NewString(""); if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { @@ -2593,6 +2622,14 @@ Printf(post_code, "\n"); 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); } else { 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 @@ excodeSubstitute(n, tm, "csout", n); bool is_pre_code = Len(pre_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 if (is_post_code) { Insert(tm, 0, "\n try "); @@ -2629,6 +2667,9 @@ Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } + if (is_terminator_code) { + Printv(tm, "\n", terminator_code, NIL); + } Insert(tm, 0, "{"); Printf(tm, "\n }"); } @@ -2704,6 +2745,7 @@ Delete(pre_code); Delete(post_code); + Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); Modified: branches/talby-perl5-improvements/Source/Modules/uffi.cxx =================================================================== --- branches/talby-perl5-improvements/Source/Modules/uffi.cxx 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/Source/Modules/uffi.cxx 2008-09-03 05:18:44 UTC (rev 10811) @@ -26,7 +26,6 @@ }; static File *f_cl = 0; -static File *f_null = 0; static struct { int count; @@ -225,16 +224,8 @@ int UFFI::top(Node *n) { String *module = Getattr(n, "name"); String *output_filename = NewString(""); - String *devnull = NewString("/dev/null"); + File *f_null = NewString(""); - f_null = NewFile(devnull, "w+"); - if (!f_null) { - FileErrorDisplay(devnull); - SWIG_exit(EXIT_FAILURE); - } - Delete(devnull); - - Printf(output_filename, "%s%s.cl", SWIG_output_directory(), module); Modified: branches/talby-perl5-improvements/configure.in =================================================================== --- branches/talby-perl5-improvements/configure.in 2008-09-03 02:45:10 UTC (rev 10810) +++ branches/talby-perl5-improvements/configure.in 2008-09-03 05:18:44 UTC (rev 10811) @@ -1129,7 +1129,7 @@ AC_MSG_CHECKING(for Ruby header files) if test -n "$RUBY"; then RUBYDIR=`($RUBY -rmkmf -e 'print Config::CONFIG[["archdir"]] || $archdir') 2>/dev/null` - if test "$RUBYDIR" != ""; then + if test x"$RUBYDIR" != x""; then dirs="$RUBYDIR" RUBYINCLUDE=none for i in $dirs; do This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |