Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(109) |
Jun
(68) |
Jul
(83) |
Aug
(126) |
Sep
(117) |
Oct
(490) |
Nov
(410) |
Dec
(182) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(15) |
Feb
(135) |
Mar
(155) |
Apr
(99) |
May
(92) |
Jun
(144) |
Jul
(51) |
Aug
(96) |
Sep
(223) |
Oct
(367) |
Nov
(346) |
Dec
(421) |
2006 |
Jan
(827) |
Feb
(404) |
Mar
(213) |
Apr
(44) |
May
(106) |
Jun
(79) |
Jul
(88) |
Aug
(43) |
Sep
(191) |
Oct
(164) |
Nov
(150) |
Dec
(36) |
2007 |
Jan
(17) |
Feb
(5) |
Mar
(17) |
Apr
(65) |
May
(114) |
Jun
(16) |
Jul
(22) |
Aug
(57) |
Sep
(44) |
Oct
(126) |
Nov
(97) |
Dec
(23) |
2008 |
Jan
(32) |
Feb
(59) |
Mar
(45) |
Apr
(80) |
May
(113) |
Jun
(116) |
Jul
(109) |
Aug
(77) |
Sep
(80) |
Oct
(10) |
Nov
(65) |
Dec
(68) |
2009 |
Jan
(77) |
Feb
(37) |
Mar
(46) |
Apr
(35) |
May
(52) |
Jun
(93) |
Jul
(150) |
Aug
(188) |
Sep
(21) |
Oct
(20) |
Nov
(46) |
Dec
(40) |
2010 |
Jan
(33) |
Feb
(56) |
Mar
(67) |
Apr
(48) |
May
(65) |
Jun
(83) |
Jul
(32) |
Aug
(10) |
Sep
(37) |
Oct
(53) |
Nov
(34) |
Dec
(39) |
2011 |
Jan
(59) |
Feb
(93) |
Mar
(72) |
Apr
(65) |
May
(79) |
Jun
(25) |
Jul
(16) |
Aug
(28) |
Sep
(22) |
Oct
(12) |
Nov
(23) |
Dec
(36) |
2012 |
Jan
(15) |
Feb
(10) |
Mar
(49) |
Apr
(66) |
May
(108) |
Jun
(74) |
Jul
(268) |
Aug
(252) |
Sep
(121) |
Oct
(24) |
Nov
(66) |
Dec
(38) |
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(9) |
Nov
(15) |
Dec
(48) |
2014 |
Jan
(18) |
Feb
(53) |
Mar
(81) |
Apr
(66) |
May
(70) |
Jun
(61) |
Jul
(38) |
Aug
(20) |
Sep
(49) |
Oct
(42) |
Nov
(13) |
Dec
(27) |
2015 |
Jan
(59) |
Feb
(27) |
Mar
(37) |
Apr
(20) |
May
(29) |
Jun
(17) |
Jul
(31) |
Aug
(27) |
Sep
(12) |
Oct
(12) |
Nov
(4) |
Dec
(24) |
2016 |
Jan
(14) |
Feb
(16) |
Mar
(38) |
Apr
(13) |
May
(30) |
Jun
(22) |
Jul
(6) |
Aug
(15) |
Sep
(23) |
Oct
(14) |
Nov
(19) |
Dec
(45) |
2017 |
Jan
(32) |
Feb
(14) |
Mar
(14) |
Apr
(8) |
May
(18) |
Jun
(21) |
Jul
(8) |
Aug
(17) |
Sep
(21) |
Oct
(22) |
Nov
(7) |
Dec
(5) |
2018 |
Jan
(15) |
Feb
(4) |
Mar
(7) |
Apr
(10) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Marcelo Matus <marcelomatus@us...> - 2004-11-05 01:41:32
|
Update of /cvsroot/swig/SWIG/Source/Swig In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7516/Source/Swig Modified Files: cwrap.c Log Message: fix def value difference between T_POINTER and T_STRING Index: cwrap.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/cwrap.c,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** cwrap.c 2 Nov 2004 08:26:54 -0000 1.46 --- cwrap.c 5 Nov 2004 01:41:07 -0000 1.47 *************** *** 186,190 **** Delete(defvalue); } ! } else if (!pvalue && (tycode == T_POINTER)) { pvalue = (String *) "0"; } --- 186,190 ---- Delete(defvalue); } ! } else if (!pvalue && ((tycode == T_POINTER) || (tycode == T_STRING))) { pvalue = (String *) "0"; } |
From: Marcelo Matus <marcelomatus@us...> - 2004-11-05 00:22:38
|
Update of /cvsroot/swig/SWIG/Examples/test-suite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22942/Examples/test-suite Modified Files: common.mk Added Files: typemap_numinputs.i Log Message: fix typemap + numinputs +argout Index: common.mk =================================================================== RCS file: /cvsroot/swig/SWIG/Examples/test-suite/common.mk,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -d -r1.118 -r1.119 *** common.mk 1 Nov 2004 22:51:05 -0000 1.118 --- common.mk 5 Nov 2004 00:22:28 -0000 1.119 *************** *** 267,270 **** --- 267,271 ---- typemap_namespace \ typemap_ns_using \ + typemap_numinputs \ typename \ union_scope \ --- NEW FILE: typemap_numinputs.i --- %module typemap_numinputs %typemap(in, numinputs=1) (char *STR, int LEN)(int temp = 0) { temp = 1; $2 = 0; $1 = 0; } %typemap(in) (int *OUTPUT) (int temp = 0) { temp = 2; $1 = &temp; } %typemap(argout) (int *OUTPUT) { temp$argnum; } %typemap(argout, numinputs=1) (char *STR, int LEN) { temp$argnum; } %typemap(in) int hello { $1 = 0; } %inline %{ int this_breaks(int hello, char *STR, int LEN, int *OUTPUT) { return LEN; } %} |
From: Marcelo Matus <marcelomatus@us...> - 2004-11-05 00:22:38
|
Update of /cvsroot/swig/SWIG/Source/Swig In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22942/Source/Swig Modified Files: typemap.c Log Message: fix typemap + numinputs +argout Index: typemap.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/typemap.c,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** typemap.c 4 Nov 2004 18:27:53 -0000 1.39 --- typemap.c 5 Nov 2004 00:22:29 -0000 1.40 *************** *** 1419,1422 **** --- 1419,1425 ---- /* Look for code fragments */ Swig_typemap_emit_code_fragments(op,firstp); + + /* increase argnum to consider numinputs */ + argnum += nmatch - 1; } } |
From: Marcelo Matus <marcelomatus@us...> - 2004-11-04 23:18:22
|
Update of /cvsroot/swig/SWIG/Source/CParse In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8371/Source/CParse Modified Files: parser.y Log Message: remove old patch for features + def arg, but save the ignore/rename part. Now everything seems to be working. Index: parser.y =================================================================== RCS file: /cvsroot/swig/SWIG/Source/CParse/parser.y,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** parser.y 4 Nov 2004 22:09:29 -0000 1.86 --- parser.y 4 Nov 2004 23:18:01 -0000 1.87 *************** *** 1089,1098 **** static void default_arguments(Node *n) { Node *function = n; ! #ifdef MARCELO ! String *fname = 0; ! String *oname = 0; ! SwigType *fdecl = 0; ! int ignore = 0; ! #endif /* Do not add in functions if kwargs is being used or if user wants old default argument wrapping --- 1089,1093 ---- static void default_arguments(Node *n) { Node *function = n; ! SwigType *fdecl = Getattr(function,"decl"); /* Do not add in functions if kwargs is being used or if user wants old default argument wrapping *************** *** 1110,1127 **** } ! #ifdef MARCELO ! if (function) { ! fdecl = Getattr(function,"decl"); /* try to see if we need to ignore this method */ ! fname = Getattr(function,"name"); ! oname = make_name(fname,fdecl); if (strncmp(Char(oname),"$ignore",7) == 0) { ignore = 1; ! } ! } ! #endif - while (function) { - ParmList *parms = Getattr(function,"parms"); if (ParmList_has_defaultargs(parms)) { --- 1105,1119 ---- } ! while (function) { ! ParmList *parms = Getattr(function,"parms"); ! /* try to see if we need to ignore this method */ ! int ignore = 0; ! String *oname = make_name(Getattr(function,"name"), fdecl); if (strncmp(Char(oname),"$ignore",7) == 0) { ignore = 1; ! oname = 0; ! } if (ParmList_has_defaultargs(parms)) { *************** *** 1133,1141 **** { Node *new_function = new_node(Copy(nodeType(function))); - #ifdef MARCELO - SwigType *decl = Copy(fdecl); - #else SwigType *decl = Copy(Getattr(function,"decl")); - #endif int constqualifier = SwigType_isconst(decl); --- 1125,1129 ---- *************** *** 1145,1153 **** SwigType_add_qualifier(decl,"const"); - #ifdef MARCELO - Setattr(new_function,"name",fname); - #else Setattr(new_function,"name",Getattr(function,"name")); - #endif Setattr(new_function,"code",Copy(Getattr(function,"code"))); Setattr(new_function,"decl", decl); --- 1133,1137 ---- *************** *** 1172,1182 **** } - #ifdef MARCELO - /* apply the original function features */ - Swig_features_get(Swig_cparse_features(),Namespaceprefix,fname,fdecl,new_function); if (ignore) Setattr(new_function,"feature:ignore","1"); - #endif ! add_symbols(new_function); /* mark added functions as ones with overloaded parameters and point to the parsed method */ Setattr(new_function,"defaultargs", n); --- 1156,1165 ---- } if (ignore) Setattr(new_function,"feature:ignore","1"); ! yyrename = oname; ! add_symbols(new_function); ! yyrename = 0; ! /* mark added functions as ones with overloaded parameters and point to the parsed method */ Setattr(new_function,"defaultargs", n); |
From: Marcelo Matus <marcelomatus@us...> - 2004-11-04 23:18:20
|
Update of /cvsroot/swig/SWIG/Examples/test-suite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8371/Examples/test-suite Modified Files: default_args.i Log Message: remove old patch for features + def arg, but save the ignore/rename part. Now everything seems to be working. Index: default_args.i =================================================================== RCS file: /cvsroot/swig/SWIG/Examples/test-suite/default_args.i,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** default_args.i 2 Nov 2004 22:45:29 -0000 1.5 --- default_args.i 4 Nov 2004 23:18:00 -0000 1.6 *************** *** 75,79 **** // Rename a class member %rename(bar2) Foo::bar; ! %rename(newname) Foo::oldname; %inline %{ --- 75,81 ---- // Rename a class member %rename(bar2) Foo::bar; ! %rename(newname) Foo::oldname(int x); ! %ignore Foo::Foo(int x, int y = 0, int z = 0); ! %inline %{ *************** *** 84,87 **** --- 86,93 ---- static int spam; + Foo(){} + + Foo(int x, int y = 0, int z = 0){} + // Use a renamed member as a default argument. SWIG has to resolve // bar to Foo::bar and not Foo::spam. SWIG-1.3.11 got this wrong. |
From: Marcelo Matus <marcelomatus@us...> - 2004-11-04 23:18:20
|
Update of /cvsroot/swig/SWIG/Examples/test-suite/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8371/Examples/test-suite/python Modified Files: default_args_runme.py Log Message: remove old patch for features + def arg, but save the ignore/rename part. Now everything seems to be working. Index: default_args_runme.py =================================================================== RCS file: /cvsroot/swig/SWIG/Examples/test-suite/python/default_args_runme.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** default_args_runme.py 3 Nov 2004 10:22:15 -0000 1.1 --- default_args_runme.py 4 Nov 2004 23:18:01 -0000 1.2 *************** *** 15,17 **** --- 15,43 ---- + f = default_args.Foo() + + f.newname() + f.newname(1) + + + try: + f = default_args.Foo(1) + error = 1 + except: + error = 0 + if error: raise RuntimeError,"ignore is not working" + + try: + f = default_args.Foo(1,2) + error = 1 + except: + error = 0 + if error: raise RuntimeError,"ignore is not working" + + try: + f = default_args.Foo(1,2,3) + error = 1 + except: + error = 0 + if error: raise RuntimeError,"ignore is not working" |
From: William Fulton <wsfulton@us...> - 2004-11-04 22:56:47
|
Update of /cvsroot/swig/SWIG In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3390 Modified Files: CHANGES.current Log Message: Index: CHANGES.current =================================================================== RCS file: /cvsroot/swig/SWIG/CHANGES.current,v retrieving revision 1.332 retrieving revision 1.333 diff -C2 -d -r1.332 -r1.333 *** CHANGES.current 4 Nov 2004 22:28:48 -0000 1.332 --- CHANGES.current 4 Nov 2004 22:56:29 -0000 1.333 *************** *** 3,6 **** --- 3,12 ---- 11/04/2004: wsfulton + [C#] Typemaps for std::vector added into std_vector.i. The proxy classes + generated are modelled on the .NET ArrayList class. This isn't quite + ready for general consumption yet, but will work with vectors of primitive + types and some classes. + + 11/04/2004: wsfulton %feature improvements for fine tuning when wrapping methods with default arguments. Any %feature targeting a method with default arguments |
From: William Fulton <wsfulton@us...> - 2004-11-04 22:37:48
|
Update of /cvsroot/swig/SWIG/Lib/csharp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31638/Lib/csharp Added Files: std_vector.i Log Message: C# std::vector support. Not really ready for the masses, but enjoy anyway. --- NEW FILE: std_vector.i --- // Warning: Use the typemaps here in the expectation that the macros they are in will change name. /* * SWIG typemaps for std::vector * C# implementation * The C# wrapper is made to look and feel like a typesafe C# ArrayList * All the methods in IList are defined, but we don't derive from IList as this is a typesafe collection. * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! */ // TODO: change ArgumentOutOfRangeException/char* Exception to ArgumentException in RemoveRange and GetRange and SetRange, Reverse(int, int) too - also add in runtime tests // TODO: use of ArgumentOutOfRangeException in enums not correct, should just mention parameter name // MACRO for use within the std::vector class body // CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps %define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...) %typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable"; %typemap(cscode) std::vector<CTYPE > %{ public $csclassname(System.Collections.ICollection c) : this() { foreach (CSTYPE element in c) { this.Add(element); } } public bool IsFixedSize { get { return false; } } public bool IsReadOnly { get { return false; } } public CSTYPE this[int index] { get { return getitem(index); } set { setitem(index, value); } } public int Capacity { get { return (int)capacity(); } set { if (value < size()) throw new ArgumentOutOfRangeException("Capacity"); reserve((uint)value); } } public int Count { get { return (int)size(); } } public bool IsSynchronized { get { return false; } } public void CopyTo(Array array) { CopyTo(0, array, 0, this.Count); } public void CopyTo(Array array, int arrayIndex) { CopyTo(0, array, arrayIndex, this.Count); } public void CopyTo(int index, System.Array array, int arrayIndex, int count) { if (array == null) { throw new ArgumentNullException("array is null."); } if (index < 0 || arrayIndex < 0 || count < 0) { throw new ArgumentOutOfRangeException("One of index, arrayIndex or count is less than zero."); } if (array.Rank > 1) { throw new ArgumentException("Multi dimensional array."); } if (index+count > this.Count || arrayIndex+count > array.Length) { throw new ArgumentException("Number of elements to copy is too large."); } for (int i=0; i<count; i++) { array.SetValue(getitemcopy(index+i), arrayIndex+i); } } // Type-safe version of IEnumerable.GetEnumerator System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return new $csclassnameEnumerator(this); } public $csclassnameEnumerator GetEnumerator() { return new $csclassnameEnumerator(this); } // Type-safe enumerator /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown /// whenever the collection is modified. This has been done for changes in the size of the /// collection but not when one of the elements of the collection is modified as it is a bit /// tricky to detect unmanaged code that modifies the collection under our feet. public sealed class $csclassnameEnumerator : System.Collections.IEnumerator { private $csclassname collectionRef; private int currentIndex; private object currentObject; private int currentSize; public $csclassnameEnumerator($csclassname collection) { collectionRef = collection; currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; } // Type-safe iterator Current public CSTYPE Current { get { if (currentIndex == -1) { throw new InvalidOperationException("Enumeration not started."); } if (currentIndex > currentSize - 1) { throw new InvalidOperationException("Enumeration finished."); } if (currentObject == null) { throw new InvalidOperationException("Collection modified."); } return (CSTYPE)currentObject; } } // Type-unsafe IEnumerator.Current object System.Collections.IEnumerator.Current { get { return Current; } } public bool MoveNext() { int size = collectionRef.Count; bool moveOkay = (currentIndex+1 < size) && (size == currentSize); if (moveOkay) { currentIndex++; currentObject = collectionRef[currentIndex]; } else { currentObject = null; } return moveOkay; } public void Reset() { currentIndex = -1; currentObject = null; if (collectionRef.Count != currentSize) { throw new InvalidOperationException("Collection modified."); } } } %} public: typedef size_t size_type; %rename(Clear) clear; void clear(); %rename(Add) push_back; void push_back(const CTYPE& value); size_type size() const; size_type capacity() const; void reserve(size_type n); %newobject GetRange(int index, int count); %newobject Repeat(const CTYPE& value, int count); vector(); %extend { vector(int capacity) { std::vector<CTYPE >* pv = 0; if (capacity >= 0) { pv = new std::vector<CTYPE >(); pv->reserve(capacity); } else { throw std::out_of_range("capacity"); } return pv; } CTYPE getitemcopy(int index) { int size = int(self->size()); if (index>=0 && index<size) return (*self)[index]; else throw std::out_of_range("index"); } const CTYPE& getitem(int index) { int size = int(self->size()); if (index>=0 && index<size) return (*self)[index]; else throw std::out_of_range("index"); } void setitem(int index, const CTYPE& value) { int size = int(self->size()); if (index>=0 && index<size) (*self)[index] = value; else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.AddRange void AddRange(const std::vector<CTYPE >& values) { self->insert(self->end(), values.begin(), values.end()); } // Takes a deep copy of the elements unlike ArrayList.GetRange std::vector<CTYPE > *GetRange(int index, int count) { if (index>=0 && index<self->size()+1) if (count >= 0 && index+count <= self->size()) return new std::vector<CTYPE >(self->begin()+index, self->begin()+index+count); else throw "count too large or negative."; else throw std::out_of_range("index"); } void Insert(int index, const CTYPE& value) { if (index>=0 && index<self->size()+1) self->insert(self->begin()+index, value); 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) { if (index>=0 && index<self->size()+1) self->insert(self->begin()+index, values.begin(), values.end()); else throw std::out_of_range("index"); } void RemoveAt(int index) { if (index>=0 && index<self->size()) self->erase(self->begin() + index); else throw std::out_of_range("index"); } void RemoveRange(int index, int count) { if (index>=0 && index<self->size()+1) if (count >= 0 && index+count <= self->size()) self->erase(self->begin()+index, self->begin()+index+count); else throw "count too large or negative."; else throw std::out_of_range("index"); } static std::vector<CTYPE > *Repeat(const CTYPE& value, int count) { if (count < 0) throw std::out_of_range("count"); return new std::vector<CTYPE >(count, value); } void Reverse() { std::reverse(self->begin(), self->end()); } void Reverse(int index, int count) { if (index>=0 && index<self->size()+1) if (count >= 0 && index+count <= self->size()) std::reverse(self->begin()+index, self->begin()+index+count); else throw "count too large or negative."; else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.SetRange void SetRange(int index, const std::vector<CTYPE >& values) { if (index>=0 && index<self->size()+1) if (index+values.size() <= self->size()) std::copy(values.begin(), values.end(), self->begin()+index); else throw "too many elements."; else throw std::out_of_range("index"); } } %enddef // Extra methods added to the collection class if operator== is defined for the class being wrapped // CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...) %extend { bool Contains(const CTYPE& value) { return std::find(self->begin(), self->end(), value) != self->end(); } int IndexOf(const CTYPE& value) { int index = -1; std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value); if (it != self->end()) index = it - self->begin(); return index; } int LastIndexOf(const CTYPE& value) { int index = -1; std::vector<CTYPE >::reverse_iterator rit = std::find(self->rbegin(), self->rend(), value); if (rit != self->rend()) index = self->rend() - 1 - rit; return index; } void Remove(const CTYPE& value) { std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value); if (it != self->end()) self->erase(it); } } %enddef // Macros for std::vector class specializations // CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps %define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...) namespace std { template<> class vector<CTYPE > { SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE) }; } %enddef %define SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE...) namespace std { template<> class vector<CTYPE > { SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE) }; } %enddef // Methods which can throw an Exception %exception std::vector::vector(int capacity) { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } } %exception std::vector::getitemcopy { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } } %exception std::vector::getitem { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } } %exception std::vector::setitem { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } } %exception std::vector::GetRange { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } catch (const char *e) { SWIG_CSharpThrowException(SWIG_CSharpException, e); } } %exception std::vector::Insert { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } } %exception std::vector::InsertRange { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } } %exception std::vector::RemoveAt { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } } %exception std::vector::Repeat { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } } %exception std::vector::RemoveRange { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } catch (const char *e) { SWIG_CSharpThrowException(SWIG_CSharpException, e); } } %exception std::vector::Reverse(int index, int count) { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } catch (const char *e) { SWIG_CSharpThrowException(SWIG_CSharpException, e); } } %exception std::vector::SetRange { try { $action } catch (std::out_of_range& e) { SWIG_CSharpThrowException(SWIG_CSharpArgumentOutOfRangeException, e.what()); } catch (const char *e) { SWIG_CSharpThrowException(SWIG_CSharpException, e); } } %{ #include <vector> #include <algorithm> #include <stdexcept> %} %csmethodmodifiers std::vector::getitemcopy "private" %csmethodmodifiers std::vector::getitem "private" %csmethodmodifiers std::vector::setitem "private" %csmethodmodifiers std::vector::size "private" %csmethodmodifiers std::vector::capacity "private" %csmethodmodifiers std::vector::reserve "private" namespace std { // primary (unspecialized) class template for std::vector // does not require operator== to be defined template<class T> class vector { SWIG_STD_VECTOR_MINIMUM(T, T) }; } // template specializations for std::vector // these provide extra collections methods as operator== is defined SWIG_STD_VECTOR_SPECIALIZE(bool, bool) SWIG_STD_VECTOR_SPECIALIZE(char, char) SWIG_STD_VECTOR_SPECIALIZE(sbyte, signed char) SWIG_STD_VECTOR_SPECIALIZE(byte, unsigned char) SWIG_STD_VECTOR_SPECIALIZE(short, short) SWIG_STD_VECTOR_SPECIALIZE(ushort, unsigned short) SWIG_STD_VECTOR_SPECIALIZE(int, int) SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned int) SWIG_STD_VECTOR_SPECIALIZE(int, long) SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned long) SWIG_STD_VECTOR_SPECIALIZE(long, long long) SWIG_STD_VECTOR_SPECIALIZE(ulong, unsigned long long) SWIG_STD_VECTOR_SPECIALIZE(float, float) SWIG_STD_VECTOR_SPECIALIZE(double, double) SWIG_STD_VECTOR_SPECIALIZE(string, std::string) // also requires a %include "std_string.i" |
From: William Fulton <wsfulton@us...> - 2004-11-04 22:29:14
|
Update of /cvsroot/swig/SWIG In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29379 Modified Files: CHANGES.current Log Message: Index: CHANGES.current =================================================================== RCS file: /cvsroot/swig/SWIG/CHANGES.current,v retrieving revision 1.331 retrieving revision 1.332 diff -C2 -d -r1.331 -r1.332 *** CHANGES.current 4 Nov 2004 01:02:19 -0000 1.331 --- CHANGES.current 4 Nov 2004 22:28:48 -0000 1.332 *************** *** 2,5 **** --- 2,42 ---- ================================= + 11/04/2004: wsfulton + %feature improvements for fine tuning when wrapping methods with + default arguments. Any %feature targeting a method with default arguments + will apply to all the extra overloaded methods that SWIG generates if the + default arguments are specified in the feature. If the default arguments are + not specified in the feature, then the feature will match that exact + wrapper method only and not the extra overloaded methods that SWIG generates. + For example: + + %feature("except") void hello(int i=0, double d=0.0); + void hello(int i=0, double d=0.0); + + will apply the feature to all three wrapper methods, that is: + + void hello(int i, double d); + void hello(int i); + void hello(); + + If the default arguments are not specified in the feature: + + %feature("except") void hello(int i, double d); + void hello(int i=0, double d=0.0); + + then the feature will only apply to this wrapper method: + + void hello(int i, double d); + + and not these wrapper methods: + + void hello(int i); + void hello(); + + This has been introduced to make %feature more powerful to ease the migration + to new default arguments wrapping approach. + + *** POTENTIAL INCOMPATIBILITY *** + 10/3/2004: wuzzeb (John Lenz) [GUILE] The -scm interface is now the default. The old GH interface can |
From: Marcelo Matus <mmatus@di...> - 2004-11-04 22:27:20
|
Oh, men, if your patch works better, just get rid of the previous one :). The idea behind the patch was more like testing where the fixes needed to be introduced, if we needed to change the inner features mechanism (naming.c), or we could workaround using what was available in the same default_argument() routine. Now, since that routine is getting large, and could require more fixes latter, maybe is better to move it to CParse/utils.c, and then we will not have to regenerate parser.c every time. Marcelo Marcelo William Fulton wrote: >Update of /cvsroot/swig/SWIG/Source/CParse >In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25416/Source/CParse > >Modified Files: > parser.y >Log Message: >Alternative %feature improvements for methods with default args, that works with constructors. >Marcelo, I've commented your approach out using #define MARCELO. Lets discuss on swig-dev. > >Index: parser.y >=================================================================== >RCS file: /cvsroot/swig/SWIG/Source/CParse/parser.y,v >retrieving revision 1.85 >retrieving revision 1.86 >diff -C2 -d -r1.85 -r1.86 >*** parser.y 4 Nov 2004 18:41:31 -0000 1.85 >--- parser.y 4 Nov 2004 22:09:29 -0000 1.86 >*************** >*** 995,1002 **** > } > >! static void new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *t, ParmList *declaratorparms, String *qualifier) { > String *fname; > String *name; > String *fixname; > if (!features_hash) features_hash = NewHash(); > fname = NewStringf("feature:%s",featurename); >--- 995,1006 ---- > } > >! static void single_new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) { > String *fname; > String *name; > String *fixname; >+ SwigType *t = Copy(type); >+ >+ /* Printf(stdout, "single_new_feature: [%s] [%s] [%s] [%s] [%s] [%s]\n", featurename, val, declaratorid, t, ParmList_str_defaultargs(declaratorparms), qualifier); */ >+ > if (!features_hash) features_hash = NewHash(); > fname = NewStringf("feature:%s",featurename); >*************** >*** 1011,1017 **** > name = fixname; > } >! if (declaratorparms) { >! Setmeta(val,"parms",declaratorparms); >! } > if (declaratorparms) Setmeta(val,"parms",declaratorparms); > if (!Len(t)) t = 0; >--- 1015,1019 ---- > name = fixname; > } >! > if (declaratorparms) Setmeta(val,"parms",declaratorparms); > if (!Len(t)) t = 0; >*************** >*** 1040,1043 **** >--- 1042,1077 ---- > } > >+ /* Add a new feature to the Hash. Additional features are added if the feature has a parameter list (declaratorparms) >+ * and one or more of the parameters have a default argument. An extra feature is added for each defaulted parameter, >+ * simulating the equivalent overloaded method. */ >+ static void new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) { >+ >+ ParmList *declparms = declaratorparms; >+ >+ /* Add the feature */ >+ single_new_feature(featurename, val, featureattribs, declaratorid, type, declaratorparms, qualifier); >+ >+ /* Add extra features if there are default parameters in the parameter list */ >+ if (type) { >+ while (declparms) { >+ if (ParmList_has_defaultargs(declparms)) { >+ >+ /* Create a parameter list for the new feature by copying all >+ but the last (defaulted) parameter */ >+ ParmList* newparms = ParmList_copy_all_except_last_parm(declparms); >+ >+ /* Create new declaration - with the last parameter removed */ >+ SwigType *newtype = Copy(type); >+ Delete(SwigType_pop_function(newtype)); /* remove the old parameter list from newtype */ >+ SwigType_add_function(newtype,newparms); >+ >+ single_new_feature(featurename, Copy(val), featureattribs, declaratorid, newtype, newparms, qualifier); >+ declparms = newparms; >+ } else { >+ declparms = 0; >+ } >+ } >+ } >+ } > > /* check if a function declaration is a plain C object */ >*************** >*** 1055,1062 **** >--- 1089,1098 ---- > static void default_arguments(Node *n) { > Node *function = n; >+ #ifdef MARCELO > String *fname = 0; > String *oname = 0; > SwigType *fdecl = 0; > int ignore = 0; >+ #endif > > /* Do not add in functions if kwargs is being used or if user wants old default argument wrapping >*************** >*** 1074,1077 **** >--- 1110,1114 ---- > } > >+ #ifdef MARCELO > if (function) { > fdecl = Getattr(function,"decl"); >*************** >*** 1083,1124 **** > } > } > > while (function) { >! /* Look for parameters with default arguments */ >! ParmList *p = Getattr(function,"parms"); >! int default_args = 0; >! while (p) { >! if (Getattr(p, "value")) { >! default_args = 1; >! break; >! } >! p = nextSibling(p); >! } >! if (default_args) { >! ParmList* newparms = 0; > /* Create a parameter list for the new function by copying all > but the last (defaulted) parameter */ >! { >! ParmList *p = Getattr(function,"parms"); >! Parm *newparm = 0; >! Parm *pp = 0; >! Parm *fp = 0; >! while (nextSibling(p)) { >! newparm = CopyParm(p); >! if (pp) { >! set_nextSibling(pp,newparm); >! } else { >! fp = newparm; >! } >! pp = newparm; >! p = nextSibling(p); >! } >! newparms = fp; >! } > > /* Create new function and add to symbol table */ > { > Node *new_function = new_node(Copy(nodeType(function))); > SwigType *decl = Copy(fdecl); > int constqualifier = SwigType_isconst(decl); > >--- 1120,1141 ---- > } > } >+ #endif > > while (function) { >! ParmList *parms = Getattr(function,"parms"); >! if (ParmList_has_defaultargs(parms)) { >! > /* Create a parameter list for the new function by copying all > but the last (defaulted) parameter */ >! ParmList* newparms = ParmList_copy_all_except_last_parm(parms); > > /* Create new function and add to symbol table */ > { > Node *new_function = new_node(Copy(nodeType(function))); >+ #ifdef MARCELO > SwigType *decl = Copy(fdecl); >+ #else >+ SwigType *decl = Copy(Getattr(function,"decl")); >+ #endif > int constqualifier = SwigType_isconst(decl); > >*************** >*** 1128,1132 **** >--- 1145,1153 ---- > SwigType_add_qualifier(decl,"const"); > >+ #ifdef MARCELO > Setattr(new_function,"name",fname); >+ #else >+ Setattr(new_function,"name",Getattr(function,"name")); >+ #endif > Setattr(new_function,"code",Copy(Getattr(function,"code"))); > Setattr(new_function,"decl", decl); >*************** >*** 1150,1158 **** > if (templateparms) Setattr(new_function,"templateparms",CopyParmList(templateparms)); > } >! > /* apply the original function features */ > Swig_features_get(Swig_cparse_features(),Namespaceprefix,fname,fdecl,new_function); > if (ignore) Setattr(new_function,"feature:ignore","1"); >! > add_symbols(new_function); > /* mark added functions as ones with overloaded parameters and point to the parsed method */ >--- 1171,1181 ---- > if (templateparms) Setattr(new_function,"templateparms",CopyParmList(templateparms)); > } >! >! #ifdef MARCELO > /* apply the original function features */ > Swig_features_get(Swig_cparse_features(),Namespaceprefix,fname,fdecl,new_function); > if (ignore) Setattr(new_function,"feature:ignore","1"); >! #endif >! > add_symbols(new_function); > /* mark added functions as ones with overloaded parameters and point to the parsed method */ > > > >------------------------------------------------------- >This SF.Net email is sponsored by: >Sybase ASE Linux Express Edition - download now for FREE >LinuxWorld Reader's Choice Award Winner for best database on Linux. >http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click >_______________________________________________ >Swig-cvs mailing list >Swig-cvs@... >https://lists.sourceforge.net/lists/listinfo/swig-cvs > > |
From: William Fulton <wsfulton@us...> - 2004-11-04 22:26:33
|
Update of /cvsroot/swig/SWIG/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28814/Lib Modified Files: swig.swg Log Message: tidy generated code up Index: swig.swg =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/swig.swg,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** swig.swg 2 Nov 2004 22:06:25 -0000 1.36 --- swig.swg 4 Nov 2004 22:26:17 -0000 1.37 *************** *** 418,422 **** ************************************************************************/ - %{ /* SWIG_TEMPLATE_DISAMBIGUATOR is needed when wrapping template calls --- 418,421 ---- *************** *** 431,434 **** --- 430,434 ---- - gcc-3.2.3 produces internal errors if you use 'template' */ + %insert("runtime") %{ #ifndef SWIG_TEMPLATE_DISAMBIGUATOR # if defined(__SUNPRO_CC) *************** *** 438,441 **** # endif #endif - %} --- 438,441 ---- # endif #endif %} + |
From: William Fulton <wsfulton@us...> - 2004-11-04 22:25:47
|
Update of /cvsroot/swig/SWIG/Doc/Manual In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28250/Doc/Manual Modified Files: Contents.html Customization.html SWIGPlus.html Log Message: %feature mods for default arguments Index: SWIGPlus.html =================================================================== RCS file: /cvsroot/swig/SWIG/Doc/Manual/SWIGPlus.html,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SWIGPlus.html 25 Oct 2004 20:38:24 -0000 1.13 --- SWIGPlus.html 4 Nov 2004 22:25:17 -0000 1.14 *************** *** 662,665 **** --- 662,670 ---- <p> + Please see the <a href="Customization.html#Customization_features_default_args">Features and default arguments</a> + section for more information on using <tt>%feature</tt> for functions with default arguments. + </p> + + <p> <b>Compatibility note:</b> Versions of SWIG prior to SWIG-1.3.23 wrapped default arguments slightly differently. Instead a single wrapper method was generated and the default values were copied into the C++ wrappers Index: Contents.html =================================================================== RCS file: /cvsroot/swig/SWIG/Doc/Manual/Contents.html,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Contents.html 3 Nov 2004 23:13:53 -0000 1.19 --- Contents.html 4 Nov 2004 22:25:16 -0000 1.20 *************** *** 378,381 **** --- 378,385 ---- <li><a href="Customization.html#ownership">Object ownership and %newobject</a> <li><a href="Customization.html#features">Features and the %feature directive</a> + <ul> + <li><a href="Customization.html#Customization_features_default_args">Features and default arguments</a> + <li><a href="Customization.html#features_example">Feature example</a> + </ul> </ul> <!-- INDEX --> Index: Customization.html =================================================================== RCS file: /cvsroot/swig/SWIG/Doc/Manual/Customization.html,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Customization.html 2 Sep 2004 20:27:13 -0000 1.10 --- Customization.html 4 Nov 2004 22:25:16 -0000 1.11 *************** *** 19,22 **** --- 19,26 ---- <li><a href="#ownership">Object ownership and %newobject</a> <li><a href="#features">Features and the %feature directive</a> + <ul> + <li><a href="#Customization_features_default_args">Features and default arguments</a> + <li><a href="#features_example">Feature example</a> + </ul> </ul> <!-- INDEX --> *************** *** 640,647 **** </blockquote> Further details can be obtained from the <a href="Java.html#exception_handling">Java exception handling</a> section. <p> ! As can be seen, the intended use for the <tt>%feature</tt> directive is as a highly flexible customization mechanism that can be used to annotate declarations with additional information for use by specific target language modules. Another example is in the Python module. You might use <tt>%feature</tt> to rewrite proxy/shadow class code as follows: --- 644,731 ---- </blockquote> + <p> Further details can be obtained from the <a href="Java.html#exception_handling">Java exception handling</a> section. + </p> + + <H3><a name="Customization_features_default_args"></a>11.3.1 Features and default arguments</H3> + <p> ! SWIG treats methods with default arguments as separate overloaded methods as detailed ! in the <a href="SWIGPlus.html#SWIGPlus_default_args">default arguments</a> section. ! Any <tt>%feature</tt> targeting a method with default arguments ! will apply to all the extra overloaded methods that SWIG generates if the ! default arguments are specified in the feature. If the default arguments are ! not specified in the feature, then the feature will match that exact ! wrapper method only and not the extra overloaded methods that SWIG generates. ! For example: ! </p> ! ! <blockquote> ! <pre> ! %feature("except") void hello(int i=0, double d=0.0); ! void hello(int i=0, double d=0.0); ! </pre> ! </blockquote> ! ! <p> ! will apply the feature to all three wrapper methods, that is: ! </p> ! ! <blockquote> ! <pre> ! void hello(int i, double d); ! void hello(int i); ! void hello(); ! </pre> ! </blockquote> ! ! <p> ! If the default arguments are not specified in the feature: ! </p> ! ! <blockquote> ! <pre> ! %feature("except") void hello(int i, double d); ! void hello(int i=0, double d=0.0); ! </pre> ! </blockquote> ! ! <p> ! then the feature will only apply to this wrapper method: ! </p> ! ! <blockquote> ! <pre> ! void hello(int i, double d); ! </pre> ! </blockquote> ! ! <p> ! and not these wrapper methods: ! </p> ! ! <blockquote> ! <pre> ! void hello(int i); ! void hello(); ! </pre> ! </blockquote> ! ! <p> ! If <a href="SWIGPlus.html#SWIGPlus_default_args">compactdefaultargs</a> are being used, then the difference between ! specifying or not specifying default arguments in a feature is not applicable as just one wrapper is generated. ! </p> ! ! <p> ! <b>Compatibility note:</b> The different behaviour of features specified with or without default arguments was introduced ! in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed. ! </p> ! ! <H3><a name="features_example"></a>11.3.2 Feature example</H3> ! ! ! <p> ! As has been shown earlier, the intended use for the <tt>%feature</tt> directive is as a highly flexible customization mechanism that can be used to annotate declarations with additional information for use by specific target language modules. Another example is in the Python module. You might use <tt>%feature</tt> to rewrite proxy/shadow class code as follows: |
From: William Fulton <wsfulton@us...> - 2004-11-04 22:11:46
|
Update of /cvsroot/swig/SWIG/Examples/test-suite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25902/Examples/test-suite Modified Files: features.i Log Message: Beefed up features test. The C++ code will fail to compile if features are not working as expected. Index: features.i =================================================================== RCS file: /cvsroot/swig/SWIG/Examples/test-suite/features.i,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** features.i 4 Nov 2004 18:41:31 -0000 1.6 --- features.i 4 Nov 2004 22:11:35 -0000 1.7 *************** *** 2,6 **** ! // This testcase checks that %feature is working for templates and non user supplied constructors/destructors // If the default %exception is used it will not compile. It shouldn't get used. --- 2,6 ---- ! // This testcase checks that %feature is working for templates and non user supplied constructors/destructors and is just generally working // If the default %exception is used it will not compile. It shouldn't get used. *************** *** 16,21 **** ! %exception NS::SimpleNS::SimpleNS() "$action /*Simple::Simple*/"; ! %exception NS::SimpleNS::~SimpleNS() "$action /*Simple::~Simple*/"; %inline %{ --- 16,25 ---- ! %exception NS::SimpleNS::SimpleNS() "$action /*NS::SimpleNS::SimpleNS*/"; ! %exception NS::SimpleNS::~SimpleNS() "$action /*NS::SimpleNS::~SimpleNS*/"; ! // method tests ! %exception NS::SimpleNS::method() "_failed_ /*NS::Simple::method() const*/"; ! %exception NS::SimpleNS::method() const "$action /*NS::Simple::method() const*/"; ! %exception NS::SimpleNS::function() "$action /*NS::Simple::function()*/"; %inline %{ *************** *** 23,27 **** { ! class SimpleNS {}; } --- 27,35 ---- { ! class SimpleNS { ! public: ! void method() const {} ! void function() {} ! }; } *************** *** 55,59 **** --- 63,72 ---- %exception Template<int>::Template(const Template&) "$action /*Template<int>::Template<int>(const Template&)*/"; %exception Template<int>::~Template() "$action /*Template<int>::~Template*/"; + // method tests %exception Template<int>::foo "$action /*Template<int>::foo*/"; + %exception Template::get "$action /*Template<int>::get*/"; + %exception Template<int>::set(const int &t) "$action /*Template<int>::set(const int &t)*/"; + %exception Template<int>::bar(const int &t) "_failed_ /*Template<int>::bar(const int &t) const*/"; + %exception Template<int>::bar(const int &t) const "$action /*Template<int>::bar(const int &t) const*/"; %inline %{ *************** *** 65,68 **** --- 78,90 ---- ~Template(){} void foo(){} + void bar(const int &t) const {} + #ifdef SWIG + %extend { + T& get(int i) const { + throw 1; + } + void set(const T &t) {} + } + #endif }; %} *************** *** 70,148 **** %template(TemplateInt) Template<int>; ! ! %exception { ! $action // default %exception ! } ! ! ! %newobject One::getSquare() const; ! ! %inline %{ ! ! struct Square ! { ! Square(int) ! { ! } ! }; ! ! struct One { ! Square *getSquare() const { return new Square(10); } ! }; ! %} ! ! %newobject Two::getSquare(); ! ! %inline %{ ! struct Two { ! Square *getSquare() const { return new Square(10); } ! }; ! ! char *foo() {return 0;} ! ! %} ! ! ! ! %exception std::Vector::get { ! $action; // get %exception ! } %inline %{ ! ! namespace std { ! ! template<class T> class Vector { ! public: ! void push_back(const T& x) {} ! #ifdef SWIG ! %extend { ! T& get(int i) { ! throw 1; ! } ! } ! #endif ! }; } - %} ! %template(VectorInt) std::Vector<int>; ! ! ! ! %ignore TROOT::TROOT(const char *name, const char *title, void *initfunc = 0); %inline %{ ! class TROOT { ! ! public: ! TROOT() ! { ! } ! ! TROOT(const char *name, const char *title, void *initfunc = 0) ! { ! } ! }; %} --- 92,132 ---- %template(TemplateInt) Template<int>; ! // Test 5: wildcards ! %exception Space::WildCards::WildCards() "$action /* Space::WildCards::WildCards() */"; ! %exception Space::WildCards::~WildCards() "$action /* Space::WildCards::WildCards() */"; ! %exception *::incy "_failure_ /* *::incy */"; ! %exception *::incy(int a) "_failure_ /* *::incy(int a) */"; ! %exception *::incy(int a) const "$action /* *::incy(int a) const */"; ! %exception *::wincy(int a) "$action /* *::wincy(int a) */"; ! %exception *::spider "$action /* *::spider */"; ! %exception *::spider(int a) "_failure_ /* *::spider(int a) */"; %inline %{ ! namespace Space { ! struct WildCards { ! virtual WildCards* incy(int a) const { return 0; } ! virtual WildCards* wincy(int a) { return 0; } ! virtual WildCards* spider(int a) const { return 0; } ! }; } %} ! // Test 6: default arguments ! %exception Space::Animals::Animals(int a = 0, double d = 0.0) "$action /* Space::Animals::Animals(int a = 0, double d = 0.0) */"; ! %exception Space::Animals::~Animals() "$action /* Space::Animals::~Animals() */"; ! %exception Space::Animals::lions(int a = 0, double d = 0.0) const "$action /* Space::Animals::lions(int a = 0, double d = 0.0) const */"; ! %exception Space::Animals::leopards(int a = 0, double d = 0.0) "$action /* Space::Animals::leopards(int a = 0, double d = 0.0) */"; ! %exception *::cheetahs(int a = 0, double d = 0.0) const "$action /* *::cheetahs(int a = 0, double d = 0.0) const */"; ! %exception *::jackal(int a = 0, double d = 0.0) "$action /* *::jackal(int a = 0, double d = 0.0) */"; %inline %{ ! namespace Space { ! struct Animals { ! Animals(int a = 0, double d = 0.0) {} ! void* lions(int a = 0, double d = 0.0) const { return 0; } ! void* leopards(int a = 0, double d = 0.0) { return 0; } ! int cheetahs(int a = 0, double d = 0.0) const { return 0; } ! int jackal(int a = 0, double d = 0.0) { return 0; } }; + } %} + |
From: William Fulton <wsfulton@us...> - 2004-11-04 22:10:32
|
Update of /cvsroot/swig/SWIG/Source/Swig In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25616/Source/Swig Modified Files: parms.c swig.h Log Message: Common default argument code factored into functions Index: swig.h =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/swig.h,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** swig.h 20 Oct 2004 20:55:47 -0000 1.96 --- swig.h 4 Nov 2004 22:10:20 -0000 1.97 *************** *** 336,339 **** --- 336,341 ---- extern String *ParmList_protostr(ParmList *); extern int ParmList_is_compactdefargs(ParmList *p); + extern int ParmList_has_defaultargs(ParmList *p); + extern ParmList *ParmList_copy_all_except_last_parm(ParmList *p); /* --- Parse tree support --- */ Index: parms.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/parms.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** parms.c 20 Oct 2004 20:55:47 -0000 1.10 --- parms.c 4 Nov 2004 22:10:19 -0000 1.11 *************** *** 249,250 **** --- 249,295 ---- + /* --------------------------------------------------------------------- + * ParmList_has_defaultargs() + * + * Returns 1 if the parameter list passed in is has one or more default + * arguments. Otherwise returns 0. + * ---------------------------------------------------------------------- */ + + int ParmList_has_defaultargs(ParmList *p) { + int default_args = 0; + while (p) { + if (Getattr(p, "value")) { + default_args = 1; + break; + } + p = nextSibling(p); + } + return default_args; + } + + /* --------------------------------------------------------------------- + * ParmList_copy_all_except_last_parm() + * + * Create a new parameter list by copying all the parameters barring the + * last parameter. + * ---------------------------------------------------------------------- */ + + ParmList *ParmList_copy_all_except_last_parm(ParmList *p) { + ParmList* newparms = 0; + Parm *newparm = 0; + Parm *pp = 0; + Parm *fp = 0; + while (nextSibling(p)) { + newparm = CopyParm(p); + if (pp) { + set_nextSibling(pp,newparm); + } else { + fp = newparm; + } + pp = newparm; + p = nextSibling(p); + } + newparms = fp; + return newparms; + } + |
From: William Fulton <wsfulton@us...> - 2004-11-04 22:10:04
|
Update of /cvsroot/swig/SWIG/Source/CParse In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25416/Source/CParse Modified Files: parser.y Log Message: Alternative %feature improvements for methods with default args, that works with constructors. Marcelo, I've commented your approach out using #define MARCELO. Lets discuss on swig-dev. Index: parser.y =================================================================== RCS file: /cvsroot/swig/SWIG/Source/CParse/parser.y,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** parser.y 4 Nov 2004 18:41:31 -0000 1.85 --- parser.y 4 Nov 2004 22:09:29 -0000 1.86 *************** *** 995,1002 **** } ! static void new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *t, ParmList *declaratorparms, String *qualifier) { String *fname; String *name; String *fixname; if (!features_hash) features_hash = NewHash(); fname = NewStringf("feature:%s",featurename); --- 995,1006 ---- } ! static void single_new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) { String *fname; String *name; String *fixname; + SwigType *t = Copy(type); + + /* Printf(stdout, "single_new_feature: [%s] [%s] [%s] [%s] [%s] [%s]\n", featurename, val, declaratorid, t, ParmList_str_defaultargs(declaratorparms), qualifier); */ + if (!features_hash) features_hash = NewHash(); fname = NewStringf("feature:%s",featurename); *************** *** 1011,1017 **** name = fixname; } ! if (declaratorparms) { ! Setmeta(val,"parms",declaratorparms); ! } if (declaratorparms) Setmeta(val,"parms",declaratorparms); if (!Len(t)) t = 0; --- 1015,1019 ---- name = fixname; } ! if (declaratorparms) Setmeta(val,"parms",declaratorparms); if (!Len(t)) t = 0; *************** *** 1040,1043 **** --- 1042,1077 ---- } + /* Add a new feature to the Hash. Additional features are added if the feature has a parameter list (declaratorparms) + * and one or more of the parameters have a default argument. An extra feature is added for each defaulted parameter, + * simulating the equivalent overloaded method. */ + static void new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) { + + ParmList *declparms = declaratorparms; + + /* Add the feature */ + single_new_feature(featurename, val, featureattribs, declaratorid, type, declaratorparms, qualifier); + + /* Add extra features if there are default parameters in the parameter list */ + if (type) { + while (declparms) { + if (ParmList_has_defaultargs(declparms)) { + + /* Create a parameter list for the new feature by copying all + but the last (defaulted) parameter */ + ParmList* newparms = ParmList_copy_all_except_last_parm(declparms); + + /* Create new declaration - with the last parameter removed */ + SwigType *newtype = Copy(type); + Delete(SwigType_pop_function(newtype)); /* remove the old parameter list from newtype */ + SwigType_add_function(newtype,newparms); + + single_new_feature(featurename, Copy(val), featureattribs, declaratorid, newtype, newparms, qualifier); + declparms = newparms; + } else { + declparms = 0; + } + } + } + } /* check if a function declaration is a plain C object */ *************** *** 1055,1062 **** --- 1089,1098 ---- static void default_arguments(Node *n) { Node *function = n; + #ifdef MARCELO String *fname = 0; String *oname = 0; SwigType *fdecl = 0; int ignore = 0; + #endif /* Do not add in functions if kwargs is being used or if user wants old default argument wrapping *************** *** 1074,1077 **** --- 1110,1114 ---- } + #ifdef MARCELO if (function) { fdecl = Getattr(function,"decl"); *************** *** 1083,1124 **** } } while (function) { ! /* Look for parameters with default arguments */ ! ParmList *p = Getattr(function,"parms"); ! int default_args = 0; ! while (p) { ! if (Getattr(p, "value")) { ! default_args = 1; ! break; ! } ! p = nextSibling(p); ! } ! if (default_args) { ! ParmList* newparms = 0; /* Create a parameter list for the new function by copying all but the last (defaulted) parameter */ ! { ! ParmList *p = Getattr(function,"parms"); ! Parm *newparm = 0; ! Parm *pp = 0; ! Parm *fp = 0; ! while (nextSibling(p)) { ! newparm = CopyParm(p); ! if (pp) { ! set_nextSibling(pp,newparm); ! } else { ! fp = newparm; ! } ! pp = newparm; ! p = nextSibling(p); ! } ! newparms = fp; ! } /* Create new function and add to symbol table */ { Node *new_function = new_node(Copy(nodeType(function))); SwigType *decl = Copy(fdecl); int constqualifier = SwigType_isconst(decl); --- 1120,1141 ---- } } + #endif while (function) { ! ParmList *parms = Getattr(function,"parms"); ! if (ParmList_has_defaultargs(parms)) { ! /* Create a parameter list for the new function by copying all but the last (defaulted) parameter */ ! ParmList* newparms = ParmList_copy_all_except_last_parm(parms); /* Create new function and add to symbol table */ { Node *new_function = new_node(Copy(nodeType(function))); + #ifdef MARCELO SwigType *decl = Copy(fdecl); + #else + SwigType *decl = Copy(Getattr(function,"decl")); + #endif int constqualifier = SwigType_isconst(decl); *************** *** 1128,1132 **** --- 1145,1153 ---- SwigType_add_qualifier(decl,"const"); + #ifdef MARCELO Setattr(new_function,"name",fname); + #else + Setattr(new_function,"name",Getattr(function,"name")); + #endif Setattr(new_function,"code",Copy(Getattr(function,"code"))); Setattr(new_function,"decl", decl); *************** *** 1150,1158 **** if (templateparms) Setattr(new_function,"templateparms",CopyParmList(templateparms)); } ! /* apply the original function features */ Swig_features_get(Swig_cparse_features(),Namespaceprefix,fname,fdecl,new_function); if (ignore) Setattr(new_function,"feature:ignore","1"); ! add_symbols(new_function); /* mark added functions as ones with overloaded parameters and point to the parsed method */ --- 1171,1181 ---- if (templateparms) Setattr(new_function,"templateparms",CopyParmList(templateparms)); } ! ! #ifdef MARCELO /* apply the original function features */ Swig_features_get(Swig_cparse_features(),Namespaceprefix,fname,fdecl,new_function); if (ignore) Setattr(new_function,"feature:ignore","1"); ! #endif ! add_symbols(new_function); /* mark added functions as ones with overloaded parameters and point to the parsed method */ |
From: William Fulton <wsfulton@us...> - 2004-11-04 22:07:07
|
Update of /cvsroot/swig/SWIG/Source/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24796/Source/Modules Modified Files: chicken.cxx Log Message: warning fix Index: chicken.cxx =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Modules/chicken.cxx,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** chicken.cxx 3 Nov 2004 23:13:59 -0000 1.23 --- chicken.cxx 4 Nov 2004 22:06:51 -0000 1.24 *************** *** 101,106 **** return new CHICKEN(); } ! extern "C" Language * swig_chicken(void) { ! return new_swig_chicken(); } --- 101,117 ---- return new CHICKEN(); } ! ! extern "C" { ! Language * swig_chicken(void) { ! return new_swig_chicken(); ! } ! ! static int checkNodeClass(Node *n) { ! String *kind = Getattr(n, "kind"); ! if (kind && Strcmp(kind, "class") == 0) ! return 1; ! else ! return 0; ! } } *************** *** 278,289 **** } - static int checkNodeClass(Node *n) { - String *kind = Getattr(n, "kind"); - if (kind && Strcmp(kind, "class") == 0) - return 1; - else - return 0; - } - int CHICKEN::functionWrapper(Node *n) --- 289,292 ---- |
From: Marcelo Matus <marcelomatus@us...> - 2004-11-04 18:44:53
|
Update of /cvsroot/swig/SWIG/Source/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6646/Source/Modules Modified Files: allocate.cxx lang.cxx Log Message: fix private new operator Index: allocate.cxx =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Modules/allocate.cxx,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** allocate.cxx 20 Oct 2004 21:39:13 -0000 1.28 --- allocate.cxx 4 Nov 2004 18:44:40 -0000 1.29 *************** *** 515,518 **** --- 515,534 ---- } + if (!Getattr(n,"allocate:has_new")) { + /* No destructor was defined. We need to check a few things here too */ + List *bases = Getattr(n,"bases"); + int allows_new = 1; + + for (int i = 0; i < Len(bases); i++) { + Node *n = Getitem(bases,i); + /* If base class does not allow default destructor, we don't allow it either */ + if (Getattr(n,"allocate:has_new")) { + allows_new = !Getattr(n,"allocate:nonew"); + } + } + if (!allows_new) { + Setattr(n,"allocate:nonew","1"); + } + } /* Check if base classes allow smart pointers, but might be hidden */ *************** *** 570,581 **** String *name = Getattr(n,"name"); if (cplus_mode != PUBLIC) { - /* Look for a private assignment operator */ if (Strcmp(name,"operator =") == 0) { Setattr(inclass,"allocate:has_assign","1"); Setattr(inclass,"allocate:noassign","1"); } } else { if (Strcmp(name,"operator =") == 0) { Setattr(inclass,"allocate:has_assign","1"); } /* Look for smart pointer operator */ --- 586,603 ---- String *name = Getattr(n,"name"); if (cplus_mode != PUBLIC) { if (Strcmp(name,"operator =") == 0) { + /* Look for a private assignment operator */ Setattr(inclass,"allocate:has_assign","1"); Setattr(inclass,"allocate:noassign","1"); + } else if (Strcmp(name,"operator new") == 0) { + /* Look for a private new operator */ + Setattr(inclass,"allocate:has_new","1"); + Setattr(inclass,"allocate:nonew","1"); } } else { if (Strcmp(name,"operator =") == 0) { Setattr(inclass,"allocate:has_assign","1"); + } else if (Strcmp(name,"operator new") == 0) { + Setattr(inclass,"allocate:has_new","1"); } /* Look for smart pointer operator */ Index: lang.cxx =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Modules/lang.cxx,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** lang.cxx 3 Nov 2004 09:57:16 -0000 1.89 --- lang.cxx 4 Nov 2004 18:44:40 -0000 1.90 *************** *** 1545,1550 **** decl = Getattr(ni, "decl"); /* extra check for function type and proper access */ ! if (SwigType_isfunction(decl) && ! (is_public(ni) || need_nonpublic_member(ni))) { String *name = Getattr(ni, "name"); String *local_decl = SwigType_typedef_resolve_all(decl); --- 1545,1551 ---- decl = Getattr(ni, "decl"); /* extra check for function type and proper access */ ! if (SwigType_isfunction(decl) ! && (is_public(n) || need_nonpublic_member(n)) ! && (is_public(ni) || need_nonpublic_member(ni))) { String *name = Getattr(ni, "name"); String *local_decl = SwigType_typedef_resolve_all(decl); *************** *** 1691,1694 **** --- 1692,1696 ---- int protected_ctor = 0; int constructor = 0; + /* emit constructors */ for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) { *************** *** 2732,2735 **** --- 2734,2740 ---- int Language::abstractClassTest(Node *n) { + /* check for non public operator new */ + if (Getattr(n,"allocate:nonew")) return 1; + /* now check for the rest */ List *abstract = Getattr(n,"abstract"); if (!abstract) return 0; |
From: Marcelo Matus <marcelomatus@us...> - 2004-11-04 18:44:52
|
Update of /cvsroot/swig/SWIG/Examples/test-suite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6646/Examples/test-suite Modified Files: private_assign.i Log Message: fix private new operator Index: private_assign.i =================================================================== RCS file: /cvsroot/swig/SWIG/Examples/test-suite/private_assign.i,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** private_assign.i 19 Oct 2004 23:39:36 -0000 1.4 --- private_assign.i 4 Nov 2004 18:44:41 -0000 1.5 *************** *** 21,24 **** --- 21,45 ---- + %inline %{ + class TROOT { + protected: + void *operator new(size_t l) { return malloc(sizeof(TROOT)); } + + public: + TROOT() + { + } + + TROOT(const char *name, const char *title, void *initfunc = 0) + { + } + }; + + class A : public TROOT + { + }; + + %} + #ifdef SWIGPYTHON *************** *** 33,35 **** --- 54,57 ---- %} + #endif |
From: Marcelo Matus <marcelomatus@us...> - 2004-11-04 18:41:54
|
Update of /cvsroot/swig/SWIG/Source/CParse In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5884/Source/CParse Modified Files: parser.y Log Message: fix %features/%rename + def args Index: parser.y =================================================================== RCS file: /cvsroot/swig/SWIG/Source/CParse/parser.y,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** parser.y 3 Nov 2004 08:07:00 -0000 1.84 --- parser.y 4 Nov 2004 18:41:31 -0000 1.85 *************** *** 197,201 **** return features_hash; } ! static String *feature_identifier_fix(String *s) { if (SwigType_istemplate(s)) { --- 197,201 ---- return features_hash; } ! static String *feature_identifier_fix(String *s) { if (SwigType_istemplate(s)) { *************** *** 1055,1058 **** --- 1055,1062 ---- static void default_arguments(Node *n) { Node *function = n; + String *fname = 0; + String *oname = 0; + SwigType *fdecl = 0; + int ignore = 0; /* Do not add in functions if kwargs is being used or if user wants old default argument wrapping *************** *** 1070,1073 **** --- 1074,1087 ---- } + if (function) { + fdecl = Getattr(function,"decl"); + /* try to see if we need to ignore this method */ + fname = Getattr(function,"name"); + oname = make_name(fname,fdecl); + if (strncmp(Char(oname),"$ignore",7) == 0) { + ignore = 1; + } + } + while (function) { /* Look for parameters with default arguments */ *************** *** 1106,1110 **** { Node *new_function = new_node(Copy(nodeType(function))); ! SwigType *decl = Copy(Getattr(function,"decl")); int constqualifier = SwigType_isconst(decl); --- 1120,1124 ---- { Node *new_function = new_node(Copy(nodeType(function))); ! SwigType *decl = Copy(fdecl); int constqualifier = SwigType_isconst(decl); *************** *** 1114,1118 **** SwigType_add_qualifier(decl,"const"); ! Setattr(new_function,"name",Copy(Getattr(function,"name"))); Setattr(new_function,"code",Copy(Getattr(function,"code"))); Setattr(new_function,"decl", decl); --- 1128,1132 ---- SwigType_add_qualifier(decl,"const"); ! Setattr(new_function,"name",fname); Setattr(new_function,"code",Copy(Getattr(function,"code"))); Setattr(new_function,"decl", decl); *************** *** 1136,1142 **** if (templateparms) Setattr(new_function,"templateparms",CopyParmList(templateparms)); } ! add_symbols(new_function); - /* mark added functions as ones with overloaded parameters and point to the parsed method */ Setattr(new_function,"defaultargs", n); --- 1150,1159 ---- if (templateparms) Setattr(new_function,"templateparms",CopyParmList(templateparms)); } ! ! /* apply the original function features */ ! Swig_features_get(Swig_cparse_features(),Namespaceprefix,fname,fdecl,new_function); ! if (ignore) Setattr(new_function,"feature:ignore","1"); ! add_symbols(new_function); /* mark added functions as ones with overloaded parameters and point to the parsed method */ Setattr(new_function,"defaultargs", n); |
From: Marcelo Matus <marcelomatus@us...> - 2004-11-04 18:41:41
|
Update of /cvsroot/swig/SWIG/Examples/test-suite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5884/Examples/test-suite Modified Files: features.i Log Message: fix %features/%rename + def args Index: features.i =================================================================== RCS file: /cvsroot/swig/SWIG/Examples/test-suite/features.i,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** features.i 2 Nov 2004 08:14:46 -0000 1.5 --- features.i 4 Nov 2004 18:41:31 -0000 1.6 *************** *** 129,130 **** --- 129,148 ---- %template(VectorInt) std::Vector<int>; + + + + %ignore TROOT::TROOT(const char *name, const char *title, void *initfunc = 0); + %inline %{ + class TROOT { + + public: + TROOT() + { + } + + TROOT(const char *name, const char *title, void *initfunc = 0) + { + } + + }; + %} |
From: Marcelo Matus <marcelomatus@us...> - 2004-11-04 18:28:03
|
Update of /cvsroot/swig/SWIG/Source/Swig In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2874 Modified Files: typemap.c Log Message: missing non-null check Index: typemap.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/typemap.c,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** typemap.c 26 Oct 2004 00:30:05 -0000 1.38 --- typemap.c 4 Nov 2004 18:27:53 -0000 1.39 *************** *** 406,410 **** if (!sm) { SwigType *ntype = SwigType_typedef_resolve(type); ! if (Cmp(ntype,type) != 0) { sm = Swig_typemap_get(ntype,name,ts); } --- 406,410 ---- if (!sm) { SwigType *ntype = SwigType_typedef_resolve(type); ! if (ntype && (Cmp(ntype,type) != 0)) { sm = Swig_typemap_get(ntype,name,ts); } |
From: Art Yerkes <arty@us...> - 2004-11-04 04:17:45
|
Update of /cvsroot/swig/SWIG/Source/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26941/Source/Modules Modified Files: ocaml.cxx Log Message: Uniform SWIGSTATIC on all prototypes. #ifdef __GNUC__ -> static inline to remove warning spew using gcc typemaps: tweaks for arrays, enums ocaml.cxx: remove Swig. qualifier everywhere it's not needed Index: ocaml.cxx =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Modules/ocaml.cxx,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** ocaml.cxx 3 Nov 2004 08:04:17 -0000 1.51 --- ocaml.cxx 4 Nov 2004 04:17:00 -0000 1.52 *************** *** 283,288 **** " (let y = _y in match (x : c_enum_type) with\n" " `unknown -> " ! " (match (Obj.magic y) with\n" ! " `Int x -> Swig.C_int x\n" " | _ -> raise (LabelNotFromThisEnum v))\n" ); --- 283,288 ---- " (let y = _y in match (x : c_enum_type) with\n" " `unknown -> " ! " (match y with\n" ! " `Int x -> (Swig.C_int x)\n" " | _ -> raise (LabelNotFromThisEnum v))\n" ); *************** *** 324,328 **** Printf( f_enum_to_int, ! ") | _ -> (Swig.C_int (get_int v))\n" "let _ = Callback.register \"%s_enum_to_int\" enum_to_int\n", module ); --- 324,328 ---- Printf( f_enum_to_int, ! ") | _ -> (C_int (get_int v))\n" "let _ = Callback.register \"%s_enum_to_int\" enum_to_int\n", module ); *************** *** 917,935 **** if( Getattr( n, "feature:immutable" ) ) { Printf( f_mlbody, ! "external _%s : Swig.c_obj -> Swig.c_obj = \"%s\" \n", mname, var_name ); ! Printf( f_mlibody, "val _%s : Swig.c_obj -> Swig.c_obj\n", iname ); if( const_enum ) { Printf( f_enum_to_int, ! " | `%s -> _%s Swig.C_void\n", mname, mname ); Printf( f_int_to_enum, ! " if y = (get_int (_%s Swig.C_void)) then `%s else\n", mname, mname ); } } else { ! Printf( f_mlbody, "external _%s : Swig.c_obj -> Swig.c_obj = \"%s\"\n", mname, var_name ); ! Printf( f_mlibody, "external _%s : Swig.c_obj -> Swig.c_obj = \"%s\"\n", mname, var_name ); } --- 917,935 ---- if( Getattr( n, "feature:immutable" ) ) { Printf( f_mlbody, ! "external _%s : c_obj -> Swig.c_obj = \"%s\" \n", mname, var_name ); ! Printf( f_mlibody, "val _%s : c_obj -> Swig.c_obj\n", iname ); if( const_enum ) { Printf( f_enum_to_int, ! " | `%s -> _%s C_void\n", mname, mname ); Printf( f_int_to_enum, ! " if y = (get_int (_%s C_void)) then `%s else\n", mname, mname ); } } else { ! Printf( f_mlbody, "external _%s : c_obj -> c_obj = \"%s\"\n", mname, var_name ); ! Printf( f_mlibody, "external _%s : c_obj -> c_obj = \"%s\"\n", mname, var_name ); } *************** *** 1205,1209 **** /* Insert sizeof operator for concrete classes */ if( sizeof_feature ) { ! Printv(f_class_ctors, "\"sizeof\" , (fun args -> Swig.C_int (__", classname, "_sizeof ())) ;\n", NIL); } --- 1205,1209 ---- /* Insert sizeof operator for concrete classes */ if( sizeof_feature ) { ! Printv(f_class_ctors, "\"sizeof\" , (fun args -> C_int (__", classname, "_sizeof ())) ;\n", NIL); } *************** *** 1217,1221 **** if (bname) { String *base_create = NewString(""); ! Printv(base_create,"(Swig.create_class \"",bname,"\")",NIL); Printv(f_class_ctors, " \"::",bname,"\", (fun args -> ", --- 1217,1221 ---- if (bname) { String *base_create = NewString(""); ! Printv(base_create,"(create_class \"",bname,"\")",NIL); Printv(f_class_ctors, " \"::",bname,"\", (fun args -> ", *************** *** 1411,1415 **** if( oname && !seen_enum ) { const_enum = true; ! Printf( f_enum_to_int, "| `%s -> (match (Obj.magic y) with\n", oname ); Printf( f_int_to_enum, "| `%s -> C_enum (\n", oname ); /* * * * A note about enum name resolution * * * * --- 1411,1415 ---- if( oname && !seen_enum ) { const_enum = true; ! Printf( f_enum_to_int, "| `%s -> (match y with\n", oname ); Printf( f_int_to_enum, "| `%s -> C_enum (\n", oname ); /* * * * A note about enum name resolution * * * * *************** *** 1756,1761 **** /* any existing helper functions to handle this? */ if (!is_void) { ! if (!SwigType_isreference(return_type)) { ! Printf(w->code, "CAMLreturn(c_result);\n"); } else { Printf(w->code, "CAMLreturn(*c_result);\n"); --- 1756,1771 ---- /* any existing helper functions to handle this? */ if (!is_void) { ! /* A little explanation: ! * The director_enum test case makes a method whose return type ! * is an enum type. return_type here is "int". gcc complains ! * about an implicit enum conversion, and although i don't strictly ! * agree with it, I'm working on fixing the error: ! * ! * Below is what I came up with. It's not great but it should ! * always essentially work. ! */ ! if( !SwigType_isreference(return_type) ) { ! Printf(w->code, "CAMLreturn((%s)c_result);\n", ! SwigType_lstr(return_type, "")); } else { Printf(w->code, "CAMLreturn(*c_result);\n"); |
From: Art Yerkes <arty@us...> - 2004-11-04 04:17:42
|
Update of /cvsroot/swig/SWIG/Lib/ocaml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26941/Lib/ocaml Modified Files: ocaml.i ocamldec.swg typemaps.i Log Message: Uniform SWIGSTATIC on all prototypes. #ifdef __GNUC__ -> static inline to remove warning spew using gcc typemaps: tweaks for arrays, enums ocaml.cxx: remove Swig. qualifier everywhere it's not needed Index: typemaps.i =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/ocaml/typemaps.i,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** typemaps.i 2 Sep 2004 20:39:25 -0000 1.19 --- typemaps.i 4 Nov 2004 04:17:00 -0000 1.20 *************** *** 285,299 **** %swigtype_ptr_out(directorin); /* C++ References */ /* Enums */ ! %typemap(in) enum SWIGTYPE { $1 = ($type)caml_long_val_full($input,"$type_marker"); } ! %typemap(varin) enum SWIGTYPE { ! $1 = ($type)caml_long_val_full($input,"$type_marker"); } ! %typemap(out) enum SWIGTYPE "$result = callback2(*caml_named_value(SWIG_MODULE \"_int_to_enum\"),*caml_named_value(\"$type_marker\"),Val_int($1));" ! %typemap(varout) enum SWIGTYPE "$result = callback2(*caml_named_value(SWIG_MODULE \"_int_to_enum\"),*caml_named_value(\"$type_marker\"),Val_int($1));" --- 285,320 ---- %swigtype_ptr_out(directorin); + %define %swigtype_array_fail(how,msg) + %typemap(how) SWIGTYPE [] { + failwith(msg); + } + %enddef + + %swigtype_array_fail(in,"Array arguments for arbitrary types need a typemap"); + %swigtype_array_fail(varin,"Assignment to global arrays for arbitrary types need a typemap"); + %swigtype_array_fail(out,"Array arguments for arbitrary types need a typemap"); + %swigtype_array_fail(varout,"Array variables need a typemap"); + %swigtype_array_fail(directorin,"Array results with arbitrary types need a typemap"); + %swigtype_array_fail(directorout,"Array arguments with arbitrary types need a typemap"); + /* C++ References */ /* Enums */ ! %define %swig_enum_in(how) ! %typemap(how) enum SWIGTYPE { $1 = ($type)caml_long_val_full($input,"$type_marker"); } + %enddef ! %define %swig_enum_out(how) ! %typemap(how) enum SWIGTYPE { ! $result = callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"),*caml_named_value("$type_marker"),Val_int((int)$1)); } + %enddef ! %swig_enum_in(in) ! %swig_enum_in(varin) ! %swig_enum_in(directorout) ! %swig_enum_out(out) ! %swig_enum_out(varout) ! %swig_enum_out(directorin) Index: ocaml.i =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/ocaml/ocaml.i,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ocaml.i 17 Oct 2004 08:38:54 -0000 1.12 --- ocaml.i 4 Nov 2004 04:17:00 -0000 1.13 *************** *** 18,25 **** %insert(mltail) %{ ! let swig_val t v = match v with ! C_enum e -> enum_to_int t v ! | _ -> Obj.magic v %} --- 18,27 ---- %insert(mltail) %{ ! let rec swig_val t v = match v with ! C_enum e -> enum_to_int t v ! | C_list l -> Swig.C_list (List.map (swig_val t) l) ! | C_array a -> Swig.C_array (Array.map (swig_val t) a) ! | _ -> Obj.magic v %} Index: ocamldec.swg =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/ocaml/ocamldec.swg,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ocamldec.swg 24 Oct 2004 08:48:05 -0000 1.12 --- ocamldec.swg 4 Nov 2004 04:17:00 -0000 1.13 *************** *** 27,30 **** --- 27,32 ---- #include <caml/misc.h> + #define caml_array_set swig_caml_array_set + // Adapted from memory.h and mlvalues.h *************** *** 80,84 **** #endif ! # define SWIGSTATIC static #define SWIG_NewPointerObj(p,type,flags) caml_val_ptr(p,type) --- 82,91 ---- #endif ! #ifdef __GNUC__ ! # define SWIGSTATIC static inline ! #else ! # define SWIGSTATIC static ! #endif ! #define SWIG_NewPointerObj(p,type,flags) caml_val_ptr(p,type) *************** *** 92,137 **** SWIG_MustGetPtr (CAML_VALUE v, swig_type_info *type); ! static CAML_VALUE _wrap_delete_void( CAML_VALUE ); ! static int enum_to_int( char *name, CAML_VALUE v ); ! static CAML_VALUE int_to_enum( char *name, int v ); ! static CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ); ! static CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ); ! static int caml_list_length( CAML_VALUE lst ); ! static CAML_VALUE caml_array_new( int n ); ! static void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ); ! static CAML_VALUE caml_array_nth( CAML_VALUE arr, int n ); ! static int caml_array_length( CAML_VALUE arr ); ! static CAML_VALUE caml_val_char( char c ); ! static CAML_VALUE caml_val_uchar( unsigned char c ); ! static CAML_VALUE caml_val_short( short s ); ! static CAML_VALUE caml_val_ushort( unsigned short s ); ! static CAML_VALUE caml_val_int( int x ); ! static CAML_VALUE caml_val_uint( unsigned int x ); ! static CAML_VALUE caml_val_long( long x ); ! static CAML_VALUE caml_val_ulong( unsigned long x ); ! static CAML_VALUE caml_val_float( float f ); ! static CAML_VALUE caml_val_double( double d ); ! static CAML_VALUE caml_val_ptr( void *p, swig_type_info *descriptor ); ! static CAML_VALUE caml_val_string( const char *str ); ! static CAML_VALUE caml_val_string_len( const char *str, int len ); ! static long caml_long_val( CAML_VALUE v ); ! static double caml_double_val( CAML_VALUE v ); ! static int caml_ptr_val_internal( CAML_VALUE v, void **out, swig_type_info *descriptor ); ! static void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ); ! static char *caml_string_val( CAML_VALUE v ); ! static int caml_string_len( CAML_VALUE v ); #ifdef __cplusplus --- 99,144 ---- SWIG_MustGetPtr (CAML_VALUE v, swig_type_info *type); ! SWIGSTATIC CAML_VALUE _wrap_delete_void( CAML_VALUE ); ! SWIGSTATIC int enum_to_int( char *name, CAML_VALUE v ); ! SWIGSTATIC CAML_VALUE int_to_enum( char *name, int v ); ! SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ); ! SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ); ! SWIGSTATIC int caml_list_length( CAML_VALUE lst ); ! SWIGSTATIC CAML_VALUE caml_array_new( int n ); ! SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ); ! SWIGSTATIC CAML_VALUE caml_array_nth( CAML_VALUE arr, int n ); ! SWIGSTATIC int caml_array_length( CAML_VALUE arr ); ! SWIGSTATIC CAML_VALUE caml_val_char( char c ); ! SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char c ); ! SWIGSTATIC CAML_VALUE caml_val_short( short s ); ! SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short s ); ! SWIGSTATIC CAML_VALUE caml_val_int( int x ); ! SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int x ); ! SWIGSTATIC CAML_VALUE caml_val_long( long x ); ! SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long x ); ! SWIGSTATIC CAML_VALUE caml_val_float( float f ); ! SWIGSTATIC CAML_VALUE caml_val_double( double d ); ! SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *descriptor ); ! SWIGSTATIC CAML_VALUE caml_val_string( const char *str ); ! SWIGSTATIC CAML_VALUE caml_val_string_len( const char *str, int len ); ! SWIGSTATIC long caml_long_val( CAML_VALUE v ); ! SWIGSTATIC double caml_double_val( CAML_VALUE v ); ! SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out, swig_type_info *descriptor ); ! SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ); ! SWIGSTATIC char *caml_string_val( CAML_VALUE v ); ! SWIGSTATIC int caml_string_len( CAML_VALUE v ); #ifdef __cplusplus |
From: Art Yerkes <arty@us...> - 2004-11-04 04:17:20
|
Update of /cvsroot/swig/SWIG/Examples/test-suite/ocaml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26941/Examples/test-suite/ocaml Modified Files: Makefile.in name_runme.ml Log Message: Uniform SWIGSTATIC on all prototypes. #ifdef __GNUC__ -> static inline to remove warning spew using gcc typemaps: tweaks for arrays, enums ocaml.cxx: remove Swig. qualifier everywhere it's not needed Index: Makefile.in =================================================================== RCS file: /cvsroot/swig/SWIG/Examples/test-suite/ocaml/Makefile.in,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.in 17 Oct 2004 07:56:17 -0000 1.5 --- Makefile.in 4 Nov 2004 04:16:59 -0000 1.6 *************** *** 20,24 **** elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ ocamlc -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ ! ocamlc swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \ ./runme) ; \ fi ; --- 20,24 ---- elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ ocamlc -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ ! ocamlc swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \ ./runme) ; \ fi ; Index: name_runme.ml =================================================================== RCS file: /cvsroot/swig/SWIG/Examples/test-suite/ocaml/name_runme.ml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** name_runme.ml 25 Oct 2003 21:17:05 -0000 1.2 --- name_runme.ml 4 Nov 2004 04:16:59 -0000 1.3 *************** *** 2,6 **** open Name ! let _ = if (get_int _Baz_2) - (get_int (_bar_2 C_void)) == 30 then exit 0 --- 2,6 ---- open Name ! let _ = if (get_int (_Baz_2 C_void)) - (get_int (_bar_2 C_void)) == 30 then exit 0 |
From: John Lenz <wuzzeb@us...> - 2004-11-04 02:20:15
|
Update of /cvsroot/swig/SWIG/Examples/test-suite/schemerunme In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9684/Examples/test-suite/schemerunme Modified Files: overload_extend.scm Log Message: Update overload_extend runme script to work properly Index: overload_extend.scm =================================================================== RCS file: /cvsroot/swig/SWIG/Examples/test-suite/schemerunme/overload_extend.scm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** overload_extend.scm 7 Jun 2004 05:03:39 -0000 1.1 --- overload_extend.scm 4 Nov 2004 02:20:04 -0000 1.2 *************** *** 7,11 **** (error "test string bad")) ! (if (not (= (Foo-test f 3.5 2.5) 3)) (error "test reals bad")) --- 7,11 ---- (error "test string bad")) ! (if (not (= (Foo-test f 3.5 2.5) 6.0)) (error "test reals bad")) |