%name replaced by %rename

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6782 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2004-11-28 19:15:04 +00:00
commit b3b4915932
2 changed files with 35 additions and 32 deletions

View file

@ -56,13 +56,13 @@ typedef struct SWIGCDATA {
* Convert raw C data to a binary string. * Convert raw C data to a binary string.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
%define %cdata(TYPE,...) %define %cdata(TYPE,NAME...)
%insert("header") { %insert("header") {
#if #__VA_ARGS__ == "" #if #NAME == ""
static SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements) { static SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements) {
#else #else
static SWIGCDATA cdata_##__VA_ARGS__(TYPE *ptr, int nelements) { static SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements) {
#endif #endif
SWIGCDATA d; SWIGCDATA d;
d.data = (char *) ptr; d.data = (char *) ptr;
@ -77,16 +77,17 @@ static SWIGCDATA cdata_##__VA_ARGS__(TYPE *ptr, int nelements) {
%typemap(default) int nelements "$1 = 1;" %typemap(default) int nelements "$1 = 1;"
#if #__VA_ARGS__ == "" #if #NAME == ""
SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements); SWIGCDATA cdata_##TYPE(TYPE *ptr, int nelements);
#else #else
SWIGCDATA cdata_##__VA_ARGS__(TYPE *ptr, int nelements); SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements);
#endif #endif
%enddef %enddef
%typemap(default) int nelements; %typemap(default) int nelements;
%name(cdata) %rename(cdata) ::cdata_void(void *ptr, int nelements);
%cdata(void); %cdata(void);
/* Memory move function */ /* Memory move function */

View file

@ -28,12 +28,13 @@
*/ */
%define %malloc(TYPE,...) %define %malloc(TYPE,NAME...)
#if #__VA_ARGS__ != "" #if #NAME != ""
%name(malloc_##__VA_ARGS__) %rename(malloc_##NAME) ::malloc(int nbytes);
#else #else
%name(malloc_##TYPE) %rename(malloc_##TYPE) ::malloc(int nbytes);
#endif #endif
#if #TYPE != "void" #if #TYPE != "void"
%typemap(default) int nbytes "$1 = (int) sizeof(TYPE);" %typemap(default) int nbytes "$1 = (int) sizeof(TYPE);"
#endif #endif
@ -41,11 +42,11 @@ TYPE *malloc(int nbytes);
%typemap(default) int nbytes; %typemap(default) int nbytes;
%enddef %enddef
%define %calloc(TYPE,...) %define %calloc(TYPE,NAME...)
#if #__VA_ARGS__ != "" #if #NAME != ""
%name(calloc_##__VA_ARGS__) %rename(calloc_##NAME) ::calloc(int nobj, int sz);
#else #else
%name(calloc_##TYPE) %rename(calloc_##TYPE) ::calloc(int nobj, int sz);
#endif #endif
#if #TYPE != "void" #if #TYPE != "void"
%typemap(default) int sz "$1 = (int) sizeof(TYPE);" %typemap(default) int sz "$1 = (int) sizeof(TYPE);"
@ -58,10 +59,10 @@ TYPE *calloc(int nobj, int sz);
%typemap(default) int nobj; %typemap(default) int nobj;
%enddef %enddef
%define %realloc(TYPE,...) %define %realloc(TYPE,NAME...)
%insert("header") { %insert("header") {
#if #__VA_ARGS__ != "" #if #NAME != ""
TYPE *realloc_##__VA_ARGS__(TYPE *ptr, int nitems) TYPE *realloc_##NAME(TYPE *ptr, int nitems)
#else #else
TYPE *realloc_##TYPE(TYPE *ptr, int nitems) TYPE *realloc_##TYPE(TYPE *ptr, int nitems)
#endif #endif
@ -73,36 +74,37 @@ return (TYPE *) realloc(ptr, nitems);
#endif #endif
} }
} }
#if #__VA_ARGS__ != "" #if #NAME != ""
TYPE *realloc_##__VA_ARGS__(TYPE *ptr, int nitems); TYPE *realloc_##NAME(TYPE *ptr, int nitems);
#else #else
TYPE *realloc_##TYPE(TYPE *ptr, int nitems); TYPE *realloc_##TYPE(TYPE *ptr, int nitems);
#endif #endif
%enddef %enddef
%define %free(TYPE,...) %define %free(TYPE,NAME...)
#if #__VA_ARGS__ != "" #if #NAME != ""
%name(free_##__VA_ARGS__) void free(TYPE *ptr); %rename(free_##NAME) ::free(TYPE *ptr);
#else #else
%name(free_##TYPE) void free(TYPE *ptr); %rename(free_##TYPE) ::free(TYPE *ptr);
#endif #endif
void free(TYPE *ptr);
%enddef %enddef
%define %sizeof(TYPE,...) %define %sizeof(TYPE,NAME...)
#if #__VA_ARGS__ != "" #if #NAME != ""
%constant int sizeof_##__VA_ARGS__ = sizeof(TYPE); %constant int sizeof_##NAME = sizeof(TYPE);
#else #else
%constant int sizeof_##TYPE = sizeof(TYPE); %constant int sizeof_##TYPE = sizeof(TYPE);
#endif #endif
%enddef %enddef
%define %allocators(TYPE,...) %define %allocators(TYPE,NAME...)
%malloc(TYPE,__VA_ARGS__) %malloc(TYPE,NAME)
%calloc(TYPE,__VA_ARGS__) %calloc(TYPE,NAME)
%realloc(TYPE,__VA_ARGS__) %realloc(TYPE,NAME)
%free(TYPE,__VA_ARGS__) %free(TYPE,NAME)
#if #TYPE != "void" #if #TYPE != "void"
%sizeof(TYPE,__VA_ARGS__) %sizeof(TYPE,NAME)
#endif #endif
%enddef %enddef