From: <wsf...@us...> - 2010-05-27 20:59:34
|
Revision: 12063 http://swig.svn.sourceforge.net/swig/?rev=12063&view=rev Author: wsfulton Date: 2010-05-27 20:59:29 +0000 (Thu, 27 May 2010) Log Message: ----------- Fix potential name clashes with symbols in the Director class Modified Paths: -------------- trunk/Lib/octave/octrun.swg Modified: trunk/Lib/octave/octrun.swg =================================================================== --- trunk/Lib/octave/octrun.swg 2010-05-27 20:55:24 UTC (rev 12062) +++ trunk/Lib/octave/octrun.swg 2010-05-27 20:59:29 UTC (rev 12063) @@ -1132,24 +1132,24 @@ namespace Swig { class Director { octave_swig_type *self; - bool disowned; + bool swig_disowned; Director(const Director &x); Director &operator=(const Director &rhs); public: - Director(void *vptr):self(0), disowned(false) { + Director(void *vptr):self(0), swig_disowned(false) { set_rtdir(vptr, this); } ~Director() { swig_director_destroyed(self, this); - if (disowned) + if (swig_disowned) self->decref(); } void swig_set_self(octave_swig_type *new_self) { - assert(!disowned); + assert(!swig_disowned); self = new_self; } @@ -1158,9 +1158,9 @@ } void swig_disown() { - if (disowned) + if (swig_disowned) return; - disowned = true; + swig_disowned = true; self->incref(); } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <xav...@us...> - 2011-05-17 01:59:25
|
Revision: 12672 http://swig.svn.sourceforge.net/swig/?rev=12672&view=rev Author: xavier98 Date: 2011-05-17 01:59:19 +0000 (Tue, 17 May 2011) Log Message: ----------- Minor improvement to the printing of Octave SWIG classes (by Karl Wette) Uses Octave's indentation functions to make sure the classes are printed at the correct indentation level, e.g. for a cell array containing SWIG-wrapped classes. Modified Paths: -------------- trunk/Lib/octave/octrun.swg Modified: trunk/Lib/octave/octrun.swg =================================================================== --- trunk/Lib/octave/octrun.swg 2011-05-17 01:57:46 UTC (rev 12671) +++ trunk/Lib/octave/octrun.swg 2011-05-17 01:59:19 UTC (rev 12672) @@ -849,26 +849,32 @@ member_map tmp; load_members(tmp); - os << "{" << std::endl; + indent(os); + os << "{"; newline(os); + increment_indent_level(); for (unsigned int j = 0; j < types.size(); ++j) { + indent(os); if (types[j].first->clientdata) { const swig_octave_class *c = (const swig_octave_class *) types[j].first->clientdata; - os << " " << c->name << ", ptr = " << types[j].second.ptr << std::endl; + os << c->name << ", ptr = " << types[j].second.ptr; newline(os); } else { - os << " " << types[j].first->name << ", ptr = " << types[j].second.ptr << std::endl; + os << types[j].first->name << ", ptr = " << types[j].second.ptr; newline(os); } } for (member_map::const_iterator it = tmp.begin(); it != tmp.end(); ++it) { + indent(os); if (it->second.first) { const char *objtype = it->second.first->method ? "method" : "variable"; const char *modifier = (it->second.first->flags &1) ? "static " : (it->second.first->flags &2) ? "global " : ""; - os << " " << it->second.first->name << " (" << modifier << objtype << ")" << std::endl; + os << it->second.first->name << " (" << modifier << objtype << ")"; newline(os); assert(it->second.first->name == it->first); } else { - os << " " << it->first << std::endl; + os << it->first; newline(os); } } - os << "}" << std::endl; + decrement_indent_level(); + indent(os); + os << "}"; newline(os); } }; @@ -998,7 +1004,8 @@ } void print(std::ostream &os, bool pr_as_read_syntax = false) const { - os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size() << std::endl; + indent(os); + os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size(); newline(os); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <xav...@us...> - 2011-05-17 02:00:31
|
Revision: 12674 http://swig.svn.sourceforge.net/swig/?rev=12674&view=rev Author: xavier98 Date: 2011-05-17 02:00:25 +0000 (Tue, 17 May 2011) Log Message: ----------- Adds support for Python __r*__ operators (by Karl Wette) The Python operator model, when evaluating e.g. x + y, is to call x.__add__(y), then y.__radd__(x) if the former does not exist, etc. This patch adds similar functionality to the SWIG runtime code. For the special case of the comparison operators __l*__ and __g*__, the reverse operators are __g*__ and __l*__ respectively. Modified Paths: -------------- trunk/Lib/octave/octrun.swg Modified: trunk/Lib/octave/octrun.swg =================================================================== --- trunk/Lib/octave/octrun.swg 2011-05-17 01:59:53 UTC (rev 12673) +++ trunk/Lib/octave/octrun.swg 2011-05-17 02:00:25 UTC (rev 12674) @@ -809,6 +809,16 @@ octave_value ret; if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name + std::string("__"), rhs, ret)) return ret; + if (rhs_ost) { + if (strlen(op_name) == 2 && (op_name[1] == 't' || op_name[1] == 'e')) { + if (op_name[0] == 'l' && rhs_ost->dispatch_binary_op(std::string("__g") + op_name[1] + std::string("__"), lhs, ret)) + return ret; + if (op_name[0] == 'g' && rhs_ost->dispatch_binary_op(std::string("__l") + op_name[1] + std::string("__"), lhs, ret)) + return ret; + } + if (rhs_ost->dispatch_binary_op(std::string("__r") + op_name + std::string("__"), lhs, ret)) + return ret; + } std::string symbol; octave_value_list args; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <xav...@us...> - 2012-02-27 17:07:50
|
Revision: 12909 http://swig.svn.sourceforge.net/swig/?rev=12909&view=rev Author: xavier98 Date: 2012-02-27 17:07:44 +0000 (Mon, 27 Feb 2012) Log Message: ----------- Comment declaration of unimplemented function swig_register_director (from Karl Wette) Modified Paths: -------------- trunk/Lib/octave/octrun.swg Modified: trunk/Lib/octave/octrun.swg =================================================================== --- trunk/Lib/octave/octrun.swg 2012-02-27 17:07:16 UTC (rev 12908) +++ trunk/Lib/octave/octrun.swg 2012-02-27 17:07:44 UTC (rev 12909) @@ -111,7 +111,7 @@ namespace Swig { class Director; - SWIGRUNTIME void swig_register_director(octave_swig_type *self, void *ptr, Director *d); + //SWIGRUNTIME void swig_register_director(octave_swig_type *self, void *ptr, Director *d); SWIGRUNTIME void swig_director_destroyed(octave_swig_type *self, Director *d); SWIGRUNTIME void swig_director_set_self(Director *d, octave_swig_type *self); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <xav...@us...> - 2012-03-26 15:38:20
|
Revision: 12954 http://swig.svn.sourceforge.net/swig/?rev=12954&view=rev Author: xavier98 Date: 2012-03-26 15:38:10 +0000 (Mon, 26 Mar 2012) Log Message: ----------- make is_object return true for swig types (patch from jgillis, sf 3424833) Modified Paths: -------------- trunk/Lib/octave/octrun.swg Modified: trunk/Lib/octave/octrun.swg =================================================================== --- trunk/Lib/octave/octrun.swg 2012-03-25 19:10:33 UTC (rev 12953) +++ trunk/Lib/octave/octrun.swg 2012-03-26 15:38:10 UTC (rev 12954) @@ -703,6 +703,10 @@ return as_value(); } + virtual bool is_object() const { + return true; + } + virtual bool is_string() const { octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); return !!nc_this->find_member("__str__", false); @@ -950,6 +954,9 @@ octave_value subsasgn(const std::string &ops, const std::list < octave_value_list > &idx, const octave_value &rhs) { return ptr->subsasgn(ops, idx, rhs); } + virtual bool is_object() const + { return ptr->is_object(); } + virtual bool is_string() const { return ptr->is_string(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kw...@us...> - 2012-05-14 09:23:55
|
Revision: 13086 http://swig.svn.sourceforge.net/swig/?rev=13086&view=rev Author: kwwette Date: 2012-05-14 09:23:45 +0000 (Mon, 14 May 2012) Log Message: ----------- New functions for handling Octave global variables - Creates a copy of the variable to be assigned to the symbol table, so it can be safely deallocated on exit Modified Paths: -------------- trunk/Lib/octave/octrun.swg Modified: trunk/Lib/octave/octrun.swg =================================================================== --- trunk/Lib/octave/octrun.swg 2012-05-14 09:23:33 UTC (rev 13085) +++ trunk/Lib/octave/octrun.swg 2012-05-14 09:23:45 UTC (rev 13086) @@ -1304,8 +1304,34 @@ module_ns->assign(name, ov); } +SWIGRUNTIMEINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name) { + return get_global_value(name, true); +} + +SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value) { + // It is critical that a newly-allocated octave_value is passed to set_global_value(), + // since it and the Octave symbol table take references to the values assigned to it. + // If we were to pass a reference to 'value' to set_global_value(), then the Octave + // symbol table would hold a reference to a variable owned by the SWIG .oct module. + // Both will think that they own the reference (since the .oct module is dynamically + // loaded, it appears to have its own C++ runtime), and so they will both try to + // de-allocate the octave_value on exit, resulting in a double-free or seg-fault. + // This is prevented by giving Octave its own heap-allocated copy of 'value'. + octave_value *pov = new octave_value(value); + set_global_value(name, *pov); +} + +SWIGRUNTIME void SWIG_Octave_LinkGlobalValue(std::string name) { +#if OCTAVE_API_VERSION_NUMBER < 37 + link_to_global_variable(curr_sym_tab->lookup(name, true)); +#else + symbol_table::varref(name); + symbol_table::mark_global(name); +#endif +} + SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata) { - octave_value ov = get_global_value("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION, true); + octave_value ov = SWIG_Octave_GetGlobalValue("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION); if (!ov.is_defined() || ov.type_id() != octave_swig_packed::static_type_id()) return 0; @@ -1318,12 +1344,5 @@ SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer) { octave_value ov = new octave_swig_packed(0, &pointer, sizeof(swig_module_info *)); - const char *module_var = "__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION; -#if OCTAVE_API_VERSION_NUMBER<37 - link_to_global_variable(curr_sym_tab->lookup(module_var, true)); -#else - symbol_table::varref(module_var); - symbol_table::mark_global(module_var); -#endif - set_global_value(module_var, ov); + SWIG_Octave_SetGlobalValue("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION, ov); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kw...@us...> - 2012-05-23 09:32:57
|
Revision: 13108 http://swig.svn.sourceforge.net/swig/?rev=13108&view=rev Author: kwwette Date: 2012-05-23 09:32:51 +0000 (Wed, 23 May 2012) Log Message: ----------- [octave] Declare these functions only if directors are used Modified Paths: -------------- trunk/Lib/octave/octrun.swg Modified: trunk/Lib/octave/octrun.swg =================================================================== --- trunk/Lib/octave/octrun.swg 2012-05-23 09:32:38 UTC (rev 13107) +++ trunk/Lib/octave/octrun.swg 2012-05-23 09:32:51 UTC (rev 13108) @@ -135,9 +135,11 @@ SWIGRUNTIME octave_swig_type *swig_value_deref(const octave_base_value &ov); } +#ifdef SWIG_DIRECTORS SWIGRUNTIME void swig_acquire_ownership(void *vptr); SWIGRUNTIME void swig_acquire_ownership_array(void *vptr); SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); +#endif struct swig_octave_member { const char *name; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |