Minor fixes:
Fix crashing bug when compiling with MSVC. Fix print of packed type of void*. Have namespaces always invoke members as statics/globals. Make SWIG_init_user function static. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10427 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ebf910f755
commit
1f38f3db67
3 changed files with 18 additions and 12 deletions
|
|
@ -180,6 +180,7 @@ namespace Swig {
|
|||
typedef std::pair < const swig_octave_member *, octave_value > member_value_pair;
|
||||
typedef std::map < std::string, member_value_pair > member_map;
|
||||
member_map members;
|
||||
bool always_static;
|
||||
|
||||
const swig_octave_member *find_member(const swig_type_info *type, const std::string &name) {
|
||||
if (!type->clientdata)
|
||||
|
|
@ -345,8 +346,10 @@ namespace Swig {
|
|||
octave_swig_type &operator=(const octave_swig_type &rhs);
|
||||
public:
|
||||
|
||||
octave_swig_type(void *_ptr = 0, const swig_type_info *_type = 0, int _own = 0)
|
||||
: module(0), construct_type(_ptr ? 0 : _type), own(_own) {
|
||||
octave_swig_type(void *_ptr = 0, const swig_type_info *_type = 0, int _own = 0,
|
||||
bool _always_static = false)
|
||||
: module(0), construct_type(_ptr ? 0 : _type), own(_own),
|
||||
always_static(_always_static) {
|
||||
if (_type || _ptr)
|
||||
types.push_back(std::make_pair(_type, _ptr));
|
||||
if (_ptr) {
|
||||
|
|
@ -570,9 +573,12 @@ namespace Swig {
|
|||
}
|
||||
|
||||
octave_value_list args;
|
||||
if (!m->first || (!m->first->is_static() && !m->first->is_global()))
|
||||
if (!always_static &&
|
||||
(!m->first || (!m->first->is_static() && !m->first->is_global())))
|
||||
args.append(as_value());
|
||||
if (skip < (int) ops.size() && ops[skip] == '(' && ((m->first && m->first->method) || m->second.is_function() || m->second.is_function_handle())) {
|
||||
if (skip < (int) ops.size() && ops[skip] == '(' &&
|
||||
((m->first && m->first->method) || m->second.is_function() ||
|
||||
m->second.is_function_handle())) {
|
||||
args.append(*idx_it++);
|
||||
++skip;
|
||||
sub_ovl = member_invoke(m, args, nargout);
|
||||
|
|
@ -902,7 +908,7 @@ namespace Swig {
|
|||
if (outtype && outtype != type)
|
||||
return false;
|
||||
assert(sz <= buf.size());
|
||||
std::copy(&buf[0], &buf[sz], (char*)ptr);
|
||||
std::copy(buf.begin(), buf.begin()+sz, (char*)ptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -919,7 +925,7 @@ namespace Swig {
|
|||
}
|
||||
|
||||
void print(std::ostream &os, bool pr_as_read_syntax = false) const {
|
||||
os << "swig packed type: name = " << type->name << ", len = " << buf.size() << std::endl;
|
||||
os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size() << std::endl;
|
||||
}
|
||||
private:
|
||||
DECLARE_OCTAVE_ALLOCATOR;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
%insert(initbeforefunc) %{
|
||||
|
||||
void SWIG_init_user(octave_swig_type* module_ns);
|
||||
static void SWIG_init_user(octave_swig_type* module_ns);
|
||||
|
||||
DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
|
||||
static bool already_init=false;
|
||||
|
|
@ -43,15 +43,12 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
|
|||
if (swig_globals[j].get_method)
|
||||
cvar_ns->assign(swig_globals[j].name,&swig_globals[j]);
|
||||
|
||||
octave_swig_type* module_ns=new octave_swig_type;
|
||||
octave_swig_type* module_ns=new octave_swig_type(0, 0, 0, true);
|
||||
module_ns->assign("cvar",Swig::swig_value_ref(cvar_ns));
|
||||
for (int j=0;swig_globals[j].name;++j)
|
||||
if (swig_globals[j].method)
|
||||
module_ns->assign(swig_globals[j].name,&swig_globals[j]);
|
||||
|
||||
link_to_global_variable(curr_sym_tab->lookup(SWIG_name_d,true));
|
||||
set_global_value(SWIG_name_d,Swig::swig_value_ref(module_ns));
|
||||
|
||||
// * need better solution here; swig_type -> octave_class mapping is
|
||||
// * really n-to-1, in some cases such as template partial spec, etc.
|
||||
// * see failing tests.
|
||||
|
|
@ -74,6 +71,9 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
|
|||
module_ns->install_global();
|
||||
module_ns->decref();
|
||||
|
||||
link_to_global_variable(curr_sym_tab->lookup(SWIG_name_d,true));
|
||||
set_global_value(SWIG_name_d,Swig::swig_value_ref(module_ns));
|
||||
|
||||
return octave_value_list();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public:
|
|||
|
||||
|
||||
Printf(s_global_tab, "\nstatic const struct swig_octave_member swig_globals[] = {\n");
|
||||
Printf(f_init, "void SWIG_init_user(octave_swig_type* module_ns)\n{\n");
|
||||
Printf(f_init, "static void SWIG_init_user(octave_swig_type* module_ns)\n{\n");
|
||||
|
||||
if (!CPlusPlus)
|
||||
Printf(f_header,"extern \"C\" {\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue