more fixes to use one line macro when possible

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8769 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2006-02-10 09:00:00 +00:00
commit 91462765db
4 changed files with 21 additions and 36 deletions

View file

@ -5,10 +5,7 @@
#ifdef __cplusplus #ifdef __cplusplus
%define %pybinoperator(pyname,oper) #define %pybinoperator(pyname,oper) %rename(pyname) oper; %pythonmaybecall oper
%rename(pyname) oper;
%pythonmaybecall oper;
%enddef
%pybinoperator(__add__, *::operator+); %pybinoperator(__add__, *::operator+);
%pybinoperator(__pos__, *::operator+()); %pybinoperator(__pos__, *::operator+());
@ -55,7 +52,7 @@
disabling the ownership of the input 'self' pointer, and assigning disabling the ownership of the input 'self' pointer, and assigning
it to the returning object: it to the returning object:
%feature("self:disown") *::Operator; %feature("del") *::Operator;
%feature("new") *::Operator; %feature("new") *::Operator;
This makes the most common case safe, ie: This makes the most common case safe, ie:
@ -75,22 +72,18 @@
that never get deleted (maybe, not sure, it depends). But if that is that never get deleted (maybe, not sure, it depends). But if that is
the case, you could recover the old behaviour using the case, you could recover the old behaviour using
%feature("self:disown","") A::operator+=; %feature("del","") A::operator+=;
%feature("new","") A::operator+=; %feature("new","") A::operator+=;
which recovers the old behaviour for the class 'A', or if you are which recovers the old behaviour for the class 'A', or if you are
100% sure your entire system works fine in the old way, use: 100% sure your entire system works fine in the old way, use:
%feature("self:disown","") *::operator+=; %feature("del","") *::operator+=;
%feature("new","") *::operator+=; %feature("new","") *::operator+=;
*/ */
%define %pyinplaceoper(PyOper, Oper) #define %pyinplaceoper(PyOper, Oper) %delobject Oper; %newobject Oper; %rename(PyOper) Oper
%feature("self:disown") Oper;
%feature("new") Oper;
%rename(PyOper) Oper;
%enddef
%pyinplaceoper(__iadd__ , *::operator +=); %pyinplaceoper(__iadd__ , *::operator +=);
%pyinplaceoper(__isub__ , *::operator -=); %pyinplaceoper(__isub__ , *::operator -=);
@ -107,10 +100,7 @@
/* Finally, in python we need to mark the binary operations to fail as /* Finally, in python we need to mark the binary operations to fail as
'maybecall' methods */ 'maybecall' methods */
%define %pybinopermaybecall(oper) #define %pybinopermaybecall(oper) %pythonmaybecall __ ## oper ## __; %pythonmaybecall __r ## oper ## __
%pythonmaybecall __ ## oper ## __;
%pythonmaybecall __r ## oper ## __;
%enddef
%pybinopermaybecall(add); %pybinopermaybecall(add);
%pybinopermaybecall(pos); %pybinopermaybecall(pos);

View file

@ -499,9 +499,7 @@ namespace std {
/* Macro for overload resolution */ /* Macro for overload resolution */
%define %typecheck(_x...) %define %typecheck(_x...) %typemap(typecheck, precedence=_x) %enddef
%typemap(typecheck, precedence=_x)
%enddef
/* Macros for precedence levels */ /* Macros for precedence levels */

View file

@ -32,31 +32,29 @@
as described above. as described above.
*/ */
/* -----------------------------------------------------------------------------
* SWIG warning codes
* ----------------------------------------------------------------------------- */
%include <swigwarn.swg> %include <swigwarn.swg>
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Auxiliar macros * Auxiliar macros
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
/* Macro to define warning messages */ /* Macro to define warning messages */
%define %_warningmsg(Val, Msg...) `Val`":"Msg %enddef #define %_warningmsg(Val, Msg...) `Val`":"Msg
%define %warningmsg(Val, Msg...) %_warningmsg(Val, Msg) %enddef #define %warningmsg(Val, Msg...) %_warningmsg(Val, Msg)
/* Macro to define warning macros */ /* Macro to define warning macros */
%define %_warningmacro(Def, Val, Msg) %define %_warningmacro(Def, Val, Msg) %define Def %warningmsg(Val, Msg) %enddef %enddef
%define Def %warningmsg(Val, Msg) %enddef #define %warningmacro(x,msg) %_warningmacro(x##_MSG, x, msg)
%enddef
%define %warningmacro(x,msg)
%_warningmacro(x##_MSG, x, msg)
%enddef
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Define typemap macro messages * Define typemap macro messages
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
%define %typemapmsg(TMap, msg) %warningmacro(SWIGWARN_TYPEMAP_##TMap,msg) %enddef #define %typemapmsg(TMap, msg) %warningmacro(SWIGWARN_TYPEMAP_##TMap,msg)
%typemapmsg(CHARLEAK, "Setting a const char * variable may leak memory.") %typemapmsg(CHARLEAK, "Setting a const char * variable may leak memory.")
%typemapmsg(SWIGTYPELEAK, "Setting a pointer/reference variable may leak memory."); %typemapmsg(SWIGTYPELEAK, "Setting a pointer/reference variable may leak memory.");
@ -73,13 +71,12 @@
* Define operator warning macro messages * Define operator warning macro messages
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
%define %ignoreopermsg(Oper, msg) %warningmacro(SWIGWARN_IGNORE_OPERATOR_##Oper,msg) %enddef #define %ignoreopermsg(Oper, msg) %warningmacro(SWIGWARN_IGNORE_OPERATOR_##Oper,msg)
%ignoreopermsg(NEW, "operator new ignored"); %ignoreopermsg(NEW, "operator new ignored");
%ignoreopermsg(DELETE, "operator delete ignored"); %ignoreopermsg(DELETE, "operator delete ignored");
%ignoreopermsg(NEWARR, "operator new[] ignored"); %ignoreopermsg(NEWARR, "operator new[] ignored");
%ignoreopermsg(DELARR, "operator delete[] ignored"); %ignoreopermsg(DELARR, "operator delete[] ignored");
%ignoreopermsg(PLUS, "operator+ ignored"); %ignoreopermsg(PLUS, "operator+ ignored");
%ignoreopermsg(MINUS, "operator- ignored"); %ignoreopermsg(MINUS, "operator- ignored");
%ignoreopermsg(MUL, "operator* ignored"); %ignoreopermsg(MUL, "operator* ignored");
@ -109,14 +106,14 @@
%ignoreopermsg(OREQ, "operator|= ignored"); %ignoreopermsg(OREQ, "operator|= ignored");
%ignoreopermsg(XOREQ, "operator^= ignored"); %ignoreopermsg(XOREQ, "operator^= ignored");
%define %ignoreoperator(Oper) %ignorewarn(SWIGWARN_IGNORE_OPERATOR_##Oper##_MSG) %enddef #define %ignoreoperator(Oper) %ignorewarn(SWIGWARN_IGNORE_OPERATOR_##Oper##_MSG)
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Macros for keyword and built-in names * Macros for keyword and built-in names
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
%define %keywordwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_KEYWORD, msg)) %enddef #define %keywordwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_KEYWORD, msg))
%define %builtinwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, msg)) %enddef #define %builtinwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, msg))
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------

View file

@ -1763,7 +1763,7 @@ Preprocessor_parse(String *s)
Seek(value,0,SEEK_SET); Seek(value,0,SEEK_SET);
Preprocessor_define(value,1); Preprocessor_define(value,1);
} }
StringPutc('\n',ns); /* StringPutc('\n',ns);*/
addline(ns,value,0); addline(ns,value,0);
state = 0; state = 0;
} }