Strip C comments from the java typemaps when determining to use the premature garbage collection prevention parameter
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9982 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a33151a48f
commit
2c46b7832c
3 changed files with 62 additions and 4 deletions
|
|
@ -2926,8 +2926,15 @@ public:
|
|||
String *prematureGarbageCollectionPreventionParameter(SwigType *t, Parm *p) {
|
||||
String *proxyClassName = 0;
|
||||
String *jtype = NewString(Getattr(p, "tmap:jtype"));
|
||||
// TODO: remove any C comments from jtype
|
||||
// remove whitespace
|
||||
|
||||
// Strip C comments
|
||||
String *stripped_jtype = Swig_strip_c_comments(jtype);
|
||||
if (stripped_jtype) {
|
||||
Delete(jtype);
|
||||
jtype = stripped_jtype;
|
||||
}
|
||||
|
||||
// Remove whitespace
|
||||
Replaceall(jtype, " ", "");
|
||||
Replaceall(jtype, "\t", "");
|
||||
|
||||
|
|
@ -2944,8 +2951,13 @@ public:
|
|||
if (jstype) {
|
||||
Hash *classes = getClassHash();
|
||||
if (classes) {
|
||||
// TODO: remove any C comments from jstype
|
||||
// remove whitespace
|
||||
// Strip C comments
|
||||
String *stripped_jstype = Swig_strip_c_comments(jstype);
|
||||
if (stripped_jstype) {
|
||||
Delete(jstype);
|
||||
jstype = stripped_jstype;
|
||||
}
|
||||
// Remove whitespace
|
||||
Replaceall(jstype, " ", "");
|
||||
Replaceall(jstype, "\t", "");
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,51 @@ void Swig_banner(File *f) {
|
|||
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_strip_c_comments()
|
||||
*
|
||||
* Return a new string with C comments stripped from the input string. Null is
|
||||
* returned if there aren't any.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_strip_c_comments(const String *s) {
|
||||
const char *c = Char(s);
|
||||
const char *comment_begin = 0;
|
||||
const char *comment_end = 0;
|
||||
while (*c) {
|
||||
if (!comment_begin && *c == '/') {
|
||||
++c;
|
||||
if (!*c)
|
||||
break;
|
||||
if (*c == '*')
|
||||
comment_begin = c-1;
|
||||
} else if (comment_begin && !comment_end && *c == '*') {
|
||||
++c;
|
||||
if (*c == '/')
|
||||
comment_end = c;
|
||||
break;
|
||||
}
|
||||
++c;
|
||||
}
|
||||
|
||||
String *stripped = 0;
|
||||
if (comment_begin && comment_end) {
|
||||
int size = comment_begin - Char(s);
|
||||
stripped = NewStringWithSize(s, size);
|
||||
Printv(stripped, comment_end + 1, NIL);
|
||||
String *stripmore = 0;
|
||||
do {
|
||||
stripmore = Swig_strip_c_comments(stripped);
|
||||
if (stripmore) {
|
||||
Delete(stripped);
|
||||
stripped = stripmore;
|
||||
}
|
||||
} while (stripmore);
|
||||
}
|
||||
return stripped;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_escape()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern void Swig_set_fakeversion(const char *version);
|
||||
extern const char *Swig_package_version(void);
|
||||
extern void Swig_banner(File *f);
|
||||
extern String *Swig_strip_c_comments(const String *s);
|
||||
extern String *Swig_string_escape(String *s);
|
||||
extern String *Swig_string_mangle(const String *s);
|
||||
extern void Swig_scopename_split(String *s, String **prefix, String **last);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue