Eliminate use of static fixed sized buffers.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9132 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7c36fe2581
commit
0137fddce5
1 changed files with 43 additions and 47 deletions
|
|
@ -895,16 +895,13 @@ public:
|
||||||
int newobject = GetFlag(n,"feature:new");
|
int newobject = GetFlag(n,"feature:new");
|
||||||
|
|
||||||
Parm *p;
|
Parm *p;
|
||||||
char source[256];
|
|
||||||
char argnum[32];
|
|
||||||
char args[32];
|
|
||||||
int i,numopt;
|
int i,numopt;
|
||||||
String *tm;
|
String *tm;
|
||||||
Wrapper *f;
|
Wrapper *f;
|
||||||
bool mvr=(shadow && php_version == 4 && wrapperType == membervar);
|
bool mvr=(shadow && php_version == 4 && wrapperType == membervar);
|
||||||
bool mvrset=(mvr && (Strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, name)))==0) );
|
bool mvrset=(mvr && (Strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, name)))==0) );
|
||||||
|
|
||||||
char wname[256];
|
String * wname;
|
||||||
int overloaded = 0;
|
int overloaded = 0;
|
||||||
String *overname = 0;
|
String *overname = 0;
|
||||||
|
|
||||||
|
|
@ -933,9 +930,9 @@ public:
|
||||||
return SWIG_ERROR;
|
return SWIG_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(wname,Char(Swig_name_wrapper(iname)));
|
wname = Swig_name_wrapper(iname);
|
||||||
if (overname) {
|
if (overname) {
|
||||||
strcat(wname,Char(overname));
|
Printf(wname, "%s", overname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if PHP4, shadow and variable wrapper we want to snag the main contents
|
// if PHP4, shadow and variable wrapper we want to snag the main contents
|
||||||
|
|
@ -992,9 +989,9 @@ public:
|
||||||
|
|
||||||
int has_this_ptr = (wrapperType==memberfn && shadow && php_version == 4);
|
int has_this_ptr = (wrapperType==memberfn && shadow && php_version == 4);
|
||||||
|
|
||||||
sprintf(args, "zval **args[%d]", num_arguments-has_this_ptr);
|
String * args = NewStringf("zval **args[%d]", num_arguments-has_this_ptr);
|
||||||
|
|
||||||
Wrapper_add_local(f, "args",args);
|
Wrapper_add_local(f, "args",args);
|
||||||
|
Delete(args); args = NULL;
|
||||||
|
|
||||||
// This generated code may be called:
|
// This generated code may be called:
|
||||||
// 1) as an object method, or
|
// 1) as an object method, or
|
||||||
|
|
@ -1051,6 +1048,8 @@ public:
|
||||||
// This may mean looking at Lang::memberfunctionhandler
|
// This may mean looking at Lang::memberfunctionhandler
|
||||||
|
|
||||||
for (i = 0, p = l; i < num_arguments; i++) {
|
for (i = 0, p = l; i < num_arguments; i++) {
|
||||||
|
String * source;
|
||||||
|
|
||||||
/* Skip ignored arguments */
|
/* Skip ignored arguments */
|
||||||
//while (Getattr(p,"tmap:ignore")) { p = Getattr(p,"tmap:ignore:next");}
|
//while (Getattr(p,"tmap:ignore")) { p = Getattr(p,"tmap:ignore:next");}
|
||||||
while (checkAttribute(p,"tmap:in:numinputs","0")) {
|
while (checkAttribute(p,"tmap:in:numinputs","0")) {
|
||||||
|
|
@ -1061,31 +1060,29 @@ public:
|
||||||
|
|
||||||
if (mvr) { // do we assert that numargs=2, that i<2
|
if (mvr) { // do we assert that numargs=2, that i<2
|
||||||
if (i==0) {
|
if (i==0) {
|
||||||
sprintf(source,"&(property_reference->object)");
|
source = NewString("&(property_reference->object)");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sprintf(source,"&value");
|
source = NewString("&value");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (i==0 && has_this_ptr ) {
|
if (i==0 && has_this_ptr) {
|
||||||
sprintf(source,"&this_ptr");
|
source = NewString("&this_ptr");
|
||||||
} else {
|
} else {
|
||||||
sprintf(source, "args[%d]", i-has_this_ptr);
|
source = NewStringf("args[%d]", i-has_this_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String *ln = Getattr(p,"lname");
|
String *ln = Getattr(p,"lname");
|
||||||
sprintf(argnum, "%d", i+1);
|
|
||||||
|
|
||||||
/* Check if optional */
|
/* Check if optional */
|
||||||
|
if(i >= num_required) {
|
||||||
if(i>= (num_required)) {
|
|
||||||
Printf(f->code,"\tif(arg_count > %d) {\n", i);
|
Printf(f->code,"\tif(arg_count > %d) {\n", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tm = Getattr(p,"tmap:in"))) {
|
if ((tm = Getattr(p,"tmap:in"))) {
|
||||||
Replaceall(tm,"$source",source);
|
Replaceall(tm,"$source", source);
|
||||||
Replaceall(tm,"$target",ln);
|
Replaceall(tm,"$target", ln);
|
||||||
Replaceall(tm,"$input", source);
|
Replaceall(tm,"$input", source);
|
||||||
Setattr(p,"emit:input", source);
|
Setattr(p,"emit:input", source);
|
||||||
Printf(f->code,"%s\n",tm);
|
Printf(f->code,"%s\n",tm);
|
||||||
|
|
@ -1102,6 +1099,7 @@ public:
|
||||||
if (i>= num_required) {
|
if (i>= num_required) {
|
||||||
Printf(f->code,"\t}\n");
|
Printf(f->code,"\t}\n");
|
||||||
}
|
}
|
||||||
|
Delete(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert constraint checking code */
|
/* Insert constraint checking code */
|
||||||
|
|
@ -1238,6 +1236,7 @@ public:
|
||||||
dispatchFunction(n);
|
dispatchFunction(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Delete(wname);
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1810,19 +1809,18 @@ public:
|
||||||
|
|
||||||
|
|
||||||
void SwigToPhpType(SwigType *t, String_or_char *pname, String* php_type, int shadow_flag) {
|
void SwigToPhpType(SwigType *t, String_or_char *pname, String* php_type, int shadow_flag) {
|
||||||
char *ptype = 0;
|
String *ptype = 0;
|
||||||
|
|
||||||
if(shadow_flag) {
|
if(shadow_flag) {
|
||||||
ptype = PhpTypeFromTypemap((char*)"pstype", t, pname,(char*)"");
|
ptype = PhpTypeFromTypemap((char*)"pstype", t, pname, (char*)"");
|
||||||
}
|
}
|
||||||
if(!ptype) {
|
if(!ptype) {
|
||||||
ptype = PhpTypeFromTypemap((char*)"ptype",t,pname,(char*)"");
|
ptype = PhpTypeFromTypemap((char*)"ptype", t, pname, (char*)"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(ptype) {
|
if(ptype) {
|
||||||
Printf(php_type, ptype);
|
Printf(php_type, "%s", ptype);
|
||||||
free(ptype);
|
Delete(ptype);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Map type here */
|
/* Map type here */
|
||||||
|
|
@ -1864,24 +1862,22 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *PhpTypeFromTypemap(char *op, SwigType *t, String_or_char *pname, String_or_char *lname) {
|
String *PhpTypeFromTypemap(char *op, SwigType *t, String_or_char *pname, String_or_char *lname) {
|
||||||
String *tms;
|
String *tms;
|
||||||
char bigbuf[1024];
|
tms = Swig_typemap_lookup(op, t, pname, lname, (char*)"", (char*)"", NULL);
|
||||||
char *tm;
|
if(!tms) {
|
||||||
char *c = bigbuf;
|
|
||||||
if(!(tms = Swig_typemap_lookup(op, t, pname, lname, (char*)"", (char*)"", NULL))) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tm = Char(tms);
|
char * start = Char(tms);
|
||||||
while(*tm && (isspace(*tm) || *tm == '{')) {
|
while(isspace(*start) || *start == '{') {
|
||||||
tm++;
|
start++;
|
||||||
}
|
}
|
||||||
while(*tm && *tm != '}') {
|
char * end = start;
|
||||||
*c++ = *tm++;
|
while(*end && *end != '}') {
|
||||||
|
end++;
|
||||||
}
|
}
|
||||||
*c='\0';
|
return NewStringWithSize(start, end - start);
|
||||||
return Swig_copy_string(bigbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int abstractConstructorHandler(Node *n) {
|
int abstractConstructorHandler(Node *n) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue