all the SwigType_add/delete methods now return the pointer of the modified type, so, we can reduce temporal variables
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7755 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
33fed0883b
commit
b3f0c0f60c
2 changed files with 40 additions and 28 deletions
|
|
@ -211,20 +211,19 @@ extern void SwigScanner_idstart(SwigScanner *, char *idchar);
|
||||||
/* --- Functions for manipulating the string-based type encoding --- */
|
/* --- Functions for manipulating the string-based type encoding --- */
|
||||||
|
|
||||||
extern SwigType *NewSwigType(int typecode);
|
extern SwigType *NewSwigType(int typecode);
|
||||||
extern void SwigType_del_element(SwigType *t);
|
extern SwigType *SwigType_del_element(SwigType *t);
|
||||||
extern void SwigType_add_pointer(SwigType *t);
|
extern SwigType *SwigType_add_pointer(SwigType *t);
|
||||||
extern void SwigType_add_memberpointer(SwigType *t, const String_or_char *qual);
|
extern SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *qual);
|
||||||
extern void SwigType_del_pointer(SwigType *t);
|
extern SwigType *SwigType_del_pointer(SwigType *t);
|
||||||
extern void SwigType_add_array(SwigType *t, const String_or_char *size);
|
extern SwigType *SwigType_add_array(SwigType *t, const String_or_char *size);
|
||||||
extern void SwigType_add_array(SwigType *t, const String_or_char *size);
|
extern SwigType *SwigType_del_array(SwigType *t);
|
||||||
extern void SwigType_del_array(SwigType *t);
|
|
||||||
extern SwigType *SwigType_pop_arrays(SwigType *t);
|
extern SwigType *SwigType_pop_arrays(SwigType *t);
|
||||||
extern void SwigType_add_reference(SwigType *t);
|
extern SwigType *SwigType_add_reference(SwigType *t);
|
||||||
extern void SwigType_del_reference(SwigType *t);
|
extern SwigType *SwigType_del_reference(SwigType *t);
|
||||||
extern void SwigType_add_qualifier(SwigType *t, const String_or_char *qual);
|
extern SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual);
|
||||||
extern void SwigType_del_qualifier(SwigType *t);
|
extern SwigType *SwigType_del_qualifier(SwigType *t);
|
||||||
extern void SwigType_add_function(SwigType *t, ParmList *parms);
|
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
|
||||||
extern void SwigType_add_template(SwigType *t, ParmList *parms);
|
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
|
||||||
extern SwigType *SwigType_pop_function(SwigType *t);
|
extern SwigType *SwigType_pop_function(SwigType *t);
|
||||||
extern ParmList *SwigType_function_parms(SwigType *t);
|
extern ParmList *SwigType_function_parms(SwigType *t);
|
||||||
extern List *SwigType_split(const SwigType *t);
|
extern List *SwigType_split(const SwigType *t);
|
||||||
|
|
|
||||||
|
|
@ -164,10 +164,11 @@ element_size(char *c) {
|
||||||
* Deletes one type element from the type.
|
* Deletes one type element from the type.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_del_element(SwigType *t) {
|
SwigType_del_element(SwigType *t) {
|
||||||
int sz = element_size(Char(t));
|
int sz = element_size(Char(t));
|
||||||
Delslice(t,0,sz);
|
Delslice(t,0,sz);
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -304,12 +305,13 @@ List *SwigType_parmlist(const String *p) {
|
||||||
* functions take into account qualifiers (if any).
|
* functions take into account qualifiers (if any).
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_add_pointer(SwigType *t) {
|
SwigType_add_pointer(SwigType *t) {
|
||||||
Insert(t,0,"p.");
|
Insert(t,0,"p.");
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_del_pointer(SwigType *t) {
|
SwigType_del_pointer(SwigType *t) {
|
||||||
char *c, *s;
|
char *c, *s;
|
||||||
c = Char(t);
|
c = Char(t);
|
||||||
|
|
@ -325,6 +327,7 @@ SwigType_del_pointer(SwigType *t) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
Delslice(t,0,(c-s)+2);
|
Delslice(t,0,(c-s)+2);
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -355,17 +358,19 @@ SwigType_ispointer(SwigType *t) {
|
||||||
* functions take into account qualifiers (if any).
|
* functions take into account qualifiers (if any).
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_add_reference(SwigType *t) {
|
SwigType_add_reference(SwigType *t) {
|
||||||
Insert(t,0,"r.");
|
Insert(t,0,"r.");
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_del_reference(SwigType *t) {
|
SwigType_del_reference(SwigType *t) {
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
int check = strncmp(c,"r.",2);
|
int check = strncmp(c,"r.",2);
|
||||||
assert(check == 0);
|
assert(check == 0);
|
||||||
Delslice(t,0,2);
|
Delslice(t,0,2);
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -393,7 +398,7 @@ SwigType_isreference(SwigType *t) {
|
||||||
* stored in exactly the same way as "q(const volatile)".
|
* stored in exactly the same way as "q(const volatile)".
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
|
SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
|
||||||
char temp[256], newq[256];
|
char temp[256], newq[256];
|
||||||
int sz, added = 0;
|
int sz, added = 0;
|
||||||
|
|
@ -405,7 +410,7 @@ SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
|
||||||
if (!(strncmp(c,"q(",2) == 0)) {
|
if (!(strncmp(c,"q(",2) == 0)) {
|
||||||
sprintf(temp,"q(%s).",cqual);
|
sprintf(temp,"q(%s).",cqual);
|
||||||
Insert(t,0,temp);
|
Insert(t,0,temp);
|
||||||
return;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The type already has a qualifier on it. In this case, we first check to
|
/* The type already has a qualifier on it. In this case, we first check to
|
||||||
|
|
@ -418,7 +423,7 @@ SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
|
||||||
|
|
||||||
if (strstr(temp,cqual)) {
|
if (strstr(temp,cqual)) {
|
||||||
/* Qualifier already added */
|
/* Qualifier already added */
|
||||||
return;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the qualifier to the existing list. */
|
/* Add the qualifier to the existing list. */
|
||||||
|
|
@ -448,14 +453,16 @@ SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
|
||||||
strcat(newq,").");
|
strcat(newq,").");
|
||||||
Delslice(t,0,sz);
|
Delslice(t,0,sz);
|
||||||
Insert(t,0,newq);
|
Insert(t,0,newq);
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_del_qualifier(SwigType *t) {
|
SwigType_del_qualifier(SwigType *t) {
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
int check = strncmp(c,"q(",2);
|
int check = strncmp(c,"q(",2);
|
||||||
assert(check == 0);
|
assert(check == 0);
|
||||||
Delslice(t,0,element_size(Char(t)));
|
Delslice(t,0,element_size(Char(t)));
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -479,19 +486,21 @@ SwigType_isqualifier(SwigType *t) {
|
||||||
* Add, remove, and test for C++ pointer to members.
|
* Add, remove, and test for C++ pointer to members.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_add_memberpointer(SwigType *t, const String_or_char *name) {
|
SwigType_add_memberpointer(SwigType *t, const String_or_char *name) {
|
||||||
String *temp = NewStringf("m(%s).", name);
|
String *temp = NewStringf("m(%s).", name);
|
||||||
Insert(t,0,temp);
|
Insert(t,0,temp);
|
||||||
Delete(temp);
|
Delete(temp);
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_del_memberpointer(SwigType *t) {
|
SwigType_del_memberpointer(SwigType *t) {
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
int check = strncmp(c,"m(",2);
|
int check = strncmp(c,"m(",2);
|
||||||
assert(check == 0);
|
assert(check == 0);
|
||||||
Delslice(t,0,element_size(c));
|
Delslice(t,0,element_size(c));
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -521,21 +530,23 @@ SwigType_ismemberpointer(SwigType *t) {
|
||||||
* SwigType_pop_arrays() - Remove all arrays
|
* SwigType_pop_arrays() - Remove all arrays
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_add_array(SwigType *t, const String_or_char *size) {
|
SwigType_add_array(SwigType *t, const String_or_char *size) {
|
||||||
char temp[512];
|
char temp[512];
|
||||||
strcpy(temp,"a(");
|
strcpy(temp,"a(");
|
||||||
strcat(temp,Char(size));
|
strcat(temp,Char(size));
|
||||||
strcat(temp,").");
|
strcat(temp,").");
|
||||||
Insert(t,0,temp);
|
Insert(t,0,temp);
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_del_array(SwigType *t) {
|
SwigType_del_array(SwigType *t) {
|
||||||
char *c = Char(t);
|
char *c = Char(t);
|
||||||
int check = strncmp(c,"a(",2);
|
int check = strncmp(c,"a(",2);
|
||||||
assert(check == 0);
|
assert(check == 0);
|
||||||
Delslice(t,0,element_size(c));
|
Delslice(t,0,element_size(c));
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SwigType_isarray(SwigType *t) {
|
int SwigType_isarray(SwigType *t) {
|
||||||
|
|
@ -642,7 +653,7 @@ SwigType_array_type(SwigType *ty) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Returns the function type, t, constructed from the parameters, parms */
|
/* Returns the function type, t, constructed from the parameters, parms */
|
||||||
void
|
SwigType *
|
||||||
SwigType_add_function(SwigType *t, ParmList *parms) {
|
SwigType_add_function(SwigType *t, ParmList *parms) {
|
||||||
String *pstr;
|
String *pstr;
|
||||||
Parm *p;
|
Parm *p;
|
||||||
|
|
@ -656,6 +667,7 @@ SwigType_add_function(SwigType *t, ParmList *parms) {
|
||||||
}
|
}
|
||||||
Insert(t,0,pstr);
|
Insert(t,0,pstr);
|
||||||
Delete(pstr);
|
Delete(pstr);
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigType *
|
SwigType *
|
||||||
|
|
@ -736,7 +748,7 @@ int SwigType_isvarargs(const SwigType *t) {
|
||||||
* vector<int *> ----> "vector<(p.int)>"
|
* vector<int *> ----> "vector<(p.int)>"
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
SwigType *
|
||||||
SwigType_add_template(SwigType *t, ParmList *parms) {
|
SwigType_add_template(SwigType *t, ParmList *parms) {
|
||||||
Parm *p;
|
Parm *p;
|
||||||
|
|
||||||
|
|
@ -754,6 +766,7 @@ SwigType_add_template(SwigType *t, ParmList *parms) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Append(t,")>");
|
Append(t,")>");
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue