Perl added to the Unified typemap library, cleaner way to use the library, and 'normalized' macro names

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7707 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-10-24 14:59:05 +00:00
commit f2f1b9889f
112 changed files with 3262 additions and 3375 deletions

View file

@ -26,6 +26,8 @@ Perl5 Options (available with -perl5)\n\
-proxy - Create proxy classes\n\
-noproxy - Don't create proxy classes\n\
-const - Wrap constants as constants and not variables (implies -proxy)\n\
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
-cppcast - Enable C++ casting operators\n\
-compat - Compatibility mode\n\n";
static int compat = 0;
@ -123,8 +125,9 @@ public:
virtual void main(int argc, char *argv[]) {
int i = 1;
int cppcast = 1;
SWIG_library_directory("perl5");
SWIG_library_directory("nperl5");
for (i = 1; i < argc; i++) {
if (argv[i]) {
if(strcmp(argv[i],"-package") == 0) {
@ -157,6 +160,12 @@ public:
i++;
pmfile = NewString(argv[i]);
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-cppcast") == 0) {
cppcast = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-nocppcast") == 0) {
cppcast = 0;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-compat") == 0) {
compat = 1;
Swig_mark_arg(i);
@ -166,6 +175,10 @@ public:
}
}
if (cppcast) {
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
}
Preprocessor_define("SWIGPERL 1", 0);
Preprocessor_define("SWIGPERL5 1", 0);
SWIG_typemap_lang("perl5");
@ -565,6 +578,13 @@ public:
Replaceall(tm,"$source",source);
Replaceall(tm,"$input", source);
Setattr(p,"emit:input",source); /* Save input location */
if (Getattr(p,"wrap:disown") || (Getattr(p,"tmap:in:disown"))) {
Replaceall(tm,"$disown","SWIG_POINTER_DISOWN");
} else {
Replaceall(tm,"$disown","0");
}
Printf(f->code,"%s\n",tm);
p = Getattr(p,"tmap:in:next");
} else {
@ -690,9 +710,9 @@ public:
"fail:\n",
cleanup,
";\n", /* empty statement */
"}\n",
"croak(Nullch);\n"
"}\n",
"}\n",
NIL);
/* Add the dXSARGS last */
@ -803,6 +823,7 @@ public:
"Unable to set variable of type %s.\n", SwigType_str(t,0));
return SWIG_NOWRAP;
}
Printf(setf->code,"fail:\n");
Printf(setf->code," return 1;\n}\n");
Replaceall(setf->code,"$symname",iname);
Wrapper_print(setf,magic);
@ -820,6 +841,11 @@ public:
Replaceall(tm,"$target","sv");
Replaceall(tm,"$result","sv");
Replaceall(tm,"$source",name);
if (is_shadow(t)) {
Replaceall(tm, "$shadow", "SWIG_SHADOW");
} else {
Replaceall(tm, "$shadow", "0");
}
Printf(getf->code,"%s\n", tm);
} else {
Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number,

View file

@ -424,6 +424,8 @@ public:
Swig_banner(f_runtime);
Printf(f_runtime,"#define SWIGRUBY\n");
if (directorsEnabled()) {
Printf(f_runtime,"#define SWIG_DIRECTORS\n");
}
@ -749,14 +751,12 @@ public:
Replaceall(tm,"$disown","0");
}
/* Are we tracking the type represented by the
* object being disowned? Note this code cannot
* go into the first part of the wrap:disown if
* statement above because that is not activated
* when the SWIGTYPE *DISOWN type map is applied. */
if (trackType(pt)) {
setTrackObjectsFlagForConvertPtr(tm);
}
Replaceall(tm, "$track","SWIG_TRACK_OBJECTS");
} else {
Replaceall(tm, "$track","0");
}
Setattr(p,"emit:input",Copy(source));
Printf(f->code,"%s\n", tm);
@ -1259,8 +1259,11 @@ public:
Replaceall(tm,"$owner", "0");
if (trackType(t)) {
setTrackObjectsFlagForNewPointer(tm);
}
Replaceall(tm, "$track","SWIG_TRACK_OBJECTS");
} else {
Replaceall(tm, "$track","0");
}
// FIXME: this will not try to unwrap directors returned as non-director
// base class pointers!
@ -1480,6 +1483,12 @@ public:
Replaceall(tm,"$result","_val");
Replaceall(tm,"$target","_val");
Replaceall(tm,"$source",name);
if (trackType(t)) {
Replaceall(tm, "$track","SWIG_TRACK_OBJECTS");
} else {
Replaceall(tm, "$track","0");
}
Printv(getf->code,tm, NIL);
} else {
Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number,
@ -1501,6 +1510,11 @@ public:
Replaceall(tm,"$input","_val");
Replaceall(tm,"$source","_val");
Replaceall(tm,"$target",name);
if (trackType(t)) {
Replaceall(tm, "$track","SWIG_TRACK_OBJECTS");
} else {
Replaceall(tm, "$track","0");
}
Printv(setf->code,tm,"\n",NIL);
} else {
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number,
@ -2404,6 +2418,7 @@ public:
sprintf(source, "obj%d", idx++);
Replaceall(tm, "$input", source);
Replaceall(tm, "$owner", "0");
Replaceall(tm, "$track", "0");
Printv(wrap_args, tm, "\n", NIL);
Wrapper_add_localv(w, source, "VALUE", source, "= Qnil", NIL);
Printv(arglist, source, NIL);
@ -2556,6 +2571,7 @@ public:
} else {
Replaceall(tm,"$disown","0");
}
Replaceall(tm,"$track","0");
Replaceall(tm, "$result", "c_result");
Printv(w->code, tm, "\n", NIL);
} else {