*** 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:
Logan Johnson 2003-04-17 23:49:17 +00:00
commit b718237c82
2 changed files with 57 additions and 18 deletions

View file

@ -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) {

View file

@ -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,6 +339,7 @@ public:
Printv(f_init, tab4, "SWIG_InitRuntime();\n", NIL); Printv(f_init, tab4, "SWIG_InitRuntime();\n", NIL);
if (!useGlobalModule)
defineRubyModule(); defineRubyModule();
Printv(f_init, Printv(f_init,
@ -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:
if (!useGlobalModule) {
Printv(s, tab4, "rb_define_module_function(", modvar, ", \"", Printv(s, tab4, "rb_define_module_function(", modvar, ", \"",
iname, "\", ", wname, ", -1);\n",NIL); iname, "\", ", wname, ", -1);\n",NIL);
Printv(f_init,s,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,6 +1074,8 @@ public:
default: default:
/* C global variable */ /* C global variable */
/* wrapped in Ruby module attribute */ /* wrapped in Ruby module attribute */
assert(current == NO_CPP);
if (!useGlobalModule) {
Printv(s, Printv(s,
tab4, "rb_define_singleton_method(", modvar, ", \"", tab4, "rb_define_singleton_method(", modvar, ", \"",
iname, "\", ", getfname, ", 0);\n", iname, "\", ", getfname, ", 0);\n",
@ -1069,6 +1086,18 @@ public:
iname, "=\", ", setfname, ", 1);\n", iname, "=\", ", setfname, ", 1);\n",
NIL); 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);
break; break;
@ -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 {
if (!useGlobalModule) {
Replaceall(tm, "$module", modvar); 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);
if (!useGlobalModule) {
Printv(klass->init, klass->vname, " = rb_define_class_under(", modvar, Printv(klass->init, klass->vname, " = rb_define_class_under(", modvar,
", \"", klass->name, "\", $super);\n", NIL); ", \"", 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);