*** empty log message ***
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4693 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f4dd14e179
commit
b718237c82
2 changed files with 57 additions and 18 deletions
|
|
@ -86,8 +86,9 @@ SWIG_ConvertPtr(VALUE obj, void **ptr, swig_type_info *ty, int flags)
|
||||||
if (NIL_P(obj)) {
|
if (NIL_P(obj)) {
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else {
|
||||||
Data_Get_Struct(obj, void, *ptr);
|
Data_Get_Struct(obj, void, *ptr);
|
||||||
|
}
|
||||||
|
|
||||||
/* Do type-checking if type info was provided */
|
/* Do type-checking if type info was provided */
|
||||||
if (ty) {
|
if (ty) {
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ private:
|
||||||
File *f_wrappers;
|
File *f_wrappers;
|
||||||
File *f_init;
|
File *f_init;
|
||||||
bool use_kw;
|
bool use_kw;
|
||||||
|
bool useGlobalModule;
|
||||||
|
|
||||||
// Wrap modes
|
// Wrap modes
|
||||||
enum {
|
enum {
|
||||||
|
|
@ -157,6 +158,7 @@ public:
|
||||||
f_wrappers = 0;
|
f_wrappers = 0;
|
||||||
f_init = 0;
|
f_init = 0;
|
||||||
use_kw = false;
|
use_kw = false;
|
||||||
|
useGlobalModule = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
|
|
@ -337,7 +339,8 @@ public:
|
||||||
|
|
||||||
Printv(f_init, tab4, "SWIG_InitRuntime();\n", NIL);
|
Printv(f_init, tab4, "SWIG_InitRuntime();\n", NIL);
|
||||||
|
|
||||||
defineRubyModule();
|
if (!useGlobalModule)
|
||||||
|
defineRubyModule();
|
||||||
|
|
||||||
Printv(f_init,
|
Printv(f_init,
|
||||||
"\n",
|
"\n",
|
||||||
|
|
@ -498,11 +501,23 @@ public:
|
||||||
Printv(klass->init, tab4, "rb_define_singleton_method(", klass->vname,
|
Printv(klass->init, tab4, "rb_define_singleton_method(", klass->vname,
|
||||||
", \"", iname, "\", ", wname, ", -1);\n", NIL);
|
", \"", iname, "\", ", wname, ", -1);\n", NIL);
|
||||||
break;
|
break;
|
||||||
default:
|
case NO_CPP:
|
||||||
Printv(s, tab4, "rb_define_module_function(", modvar, ", \"",
|
if (!useGlobalModule) {
|
||||||
iname, "\", ", wname, ", -1);\n",NIL);
|
Printv(s, tab4, "rb_define_module_function(", modvar, ", \"",
|
||||||
Printv(f_init,s,NIL);
|
iname, "\", ", wname, ", -1);\n",NIL);
|
||||||
|
Printv(f_init,s,NIL);
|
||||||
|
} else {
|
||||||
|
Printv(s, tab4, "rb_define_global_function(\"",
|
||||||
|
iname, "\", ", wname, ", -1);\n",NIL);
|
||||||
|
Printv(f_init,s,NIL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
case DESTRUCTOR:
|
||||||
|
case CLASS_CONST:
|
||||||
|
case STATIC_VAR:
|
||||||
|
assert(false); // Should not have gotten here for these types
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
defineAliases(n, iname);
|
defineAliases(n, iname);
|
||||||
|
|
@ -1059,15 +1074,29 @@ public:
|
||||||
default:
|
default:
|
||||||
/* C global variable */
|
/* C global variable */
|
||||||
/* wrapped in Ruby module attribute */
|
/* wrapped in Ruby module attribute */
|
||||||
Printv(s,
|
assert(current == NO_CPP);
|
||||||
tab4, "rb_define_singleton_method(", modvar, ", \"",
|
if (!useGlobalModule) {
|
||||||
iname, "\", ", getfname, ", 0);\n",
|
Printv(s,
|
||||||
NIL);
|
tab4, "rb_define_singleton_method(", modvar, ", \"",
|
||||||
if (!Getattr(n,"feature:immutable")) {
|
iname, "\", ", getfname, ", 0);\n",
|
||||||
Printv(s,
|
NIL);
|
||||||
tab4, "rb_define_singleton_method(", modvar, ", \"",
|
if (!Getattr(n,"feature:immutable")) {
|
||||||
iname, "=\", ", setfname, ", 1);\n",
|
Printv(s,
|
||||||
NIL);
|
tab4, "rb_define_singleton_method(", modvar, ", \"",
|
||||||
|
iname, "=\", ", setfname, ", 1);\n",
|
||||||
|
NIL);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Printv(s,
|
||||||
|
tab4, "rb_define_global_method(\"",
|
||||||
|
iname, "\", ", getfname, ", 0);\n",
|
||||||
|
NIL);
|
||||||
|
if (!Getattr(n,"feature:immutable")) {
|
||||||
|
Printv(s,
|
||||||
|
tab4, "rb_define_global_method(\"",
|
||||||
|
iname, "=\", ", setfname, ", 1);\n",
|
||||||
|
NIL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Printv(f_init,s,NIL);
|
Printv(f_init,s,NIL);
|
||||||
Delete(s);
|
Delete(s);
|
||||||
|
|
@ -1141,7 +1170,11 @@ public:
|
||||||
Replaceall(tm, "$module", klass->vname);
|
Replaceall(tm, "$module", klass->vname);
|
||||||
Printv(klass->init, tm, "\n", NIL);
|
Printv(klass->init, tm, "\n", NIL);
|
||||||
} else {
|
} else {
|
||||||
Replaceall(tm,"$module", modvar);
|
if (!useGlobalModule) {
|
||||||
|
Replaceall(tm, "$module", modvar);
|
||||||
|
} else {
|
||||||
|
Replaceall(tm, "$module", "rb_cObject");
|
||||||
|
}
|
||||||
Printf(f_init, "%s\n", tm);
|
Printf(f_init, "%s\n", tm);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1304,8 +1337,13 @@ public:
|
||||||
Printv(klass->type, Getattr(n,"classtype"), NIL);
|
Printv(klass->type, Getattr(n,"classtype"), NIL);
|
||||||
Printv(klass->header, "\nswig_class c", valid_name, ";\n", NIL);
|
Printv(klass->header, "\nswig_class c", valid_name, ";\n", NIL);
|
||||||
Printv(klass->init, "\n", tab4, NIL);
|
Printv(klass->init, "\n", tab4, NIL);
|
||||||
Printv(klass->init, klass->vname, " = rb_define_class_under(", modvar,
|
if (!useGlobalModule) {
|
||||||
", \"", klass->name, "\", $super);\n", NIL);
|
Printv(klass->init, klass->vname, " = rb_define_class_under(", modvar,
|
||||||
|
", \"", klass->name, "\", $super);\n", NIL);
|
||||||
|
} else {
|
||||||
|
Printv(klass->init, klass->vname, " = rb_define_class_under(\"",
|
||||||
|
klass->name, "\", $super);\n", NIL);
|
||||||
|
}
|
||||||
|
|
||||||
SwigType *tt = NewString(name);
|
SwigType *tt = NewString(name);
|
||||||
SwigType_add_pointer(tt);
|
SwigType_add_pointer(tt);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue