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
%define %pybinoperator(pyname,oper)
%rename(pyname) oper;
%pythonmaybecall oper;
%enddef
#define %pybinoperator(pyname,oper) %rename(pyname) oper; %pythonmaybecall oper
%pybinoperator(__add__, *::operator+);
%pybinoperator(__pos__, *::operator+());
@ -55,7 +52,7 @@
disabling the ownership of the input 'self' pointer, and assigning
it to the returning object:
%feature("self:disown") *::Operator;
%feature("del") *::Operator;
%feature("new") *::Operator;
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
the case, you could recover the old behaviour using
%feature("self:disown","") A::operator+=;
%feature("del","") A::operator+=;
%feature("new","") A::operator+=;
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:
%feature("self:disown","") *::operator+=;
%feature("del","") *::operator+=;
%feature("new","") *::operator+=;
*/
%define %pyinplaceoper(PyOper, Oper)
%feature("self:disown") Oper;
%feature("new") Oper;
%rename(PyOper) Oper;
%enddef
#define %pyinplaceoper(PyOper, Oper) %delobject Oper; %newobject Oper; %rename(PyOper) Oper
%pyinplaceoper(__iadd__ , *::operator +=);
%pyinplaceoper(__isub__ , *::operator -=);
@ -107,10 +100,7 @@
/* Finally, in python we need to mark the binary operations to fail as
'maybecall' methods */
%define %pybinopermaybecall(oper)
%pythonmaybecall __ ## oper ## __;
%pythonmaybecall __r ## oper ## __;
%enddef
#define %pybinopermaybecall(oper) %pythonmaybecall __ ## oper ## __; %pythonmaybecall __r ## oper ## __
%pybinopermaybecall(add);
%pybinopermaybecall(pos);

View file

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

View file

@ -32,31 +32,29 @@
as described above.
*/
/* -----------------------------------------------------------------------------
* SWIG warning codes
* ----------------------------------------------------------------------------- */
%include <swigwarn.swg>
/* -----------------------------------------------------------------------------
* Auxiliar macros
* ----------------------------------------------------------------------------- */
/* Macro to define warning messages */
%define %_warningmsg(Val, Msg...) `Val`":"Msg %enddef
%define %warningmsg(Val, Msg...) %_warningmsg(Val, Msg) %enddef
#define %_warningmsg(Val, Msg...) `Val`":"Msg
#define %warningmsg(Val, Msg...) %_warningmsg(Val, Msg)
/* Macro to define warning macros */
%define %_warningmacro(Def, Val, Msg)
%define Def %warningmsg(Val, Msg) %enddef
%enddef
%define %warningmacro(x,msg)
%_warningmacro(x##_MSG, x, msg)
%enddef
%define %_warningmacro(Def, Val, Msg) %define Def %warningmsg(Val, Msg) %enddef %enddef
#define %warningmacro(x,msg) %_warningmacro(x##_MSG, x, msg)
/* -----------------------------------------------------------------------------
* 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(SWIGTYPELEAK, "Setting a pointer/reference variable may leak memory.");
@ -73,13 +71,12 @@
* 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(DELETE, "operator delete ignored");
%ignoreopermsg(NEWARR, "operator new[] ignored");
%ignoreopermsg(DELARR, "operator delete[] ignored");
%ignoreopermsg(PLUS, "operator+ ignored");
%ignoreopermsg(MINUS, "operator- ignored");
%ignoreopermsg(MUL, "operator* ignored");
@ -109,14 +106,14 @@
%ignoreopermsg(OREQ, "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
* ----------------------------------------------------------------------------- */
%define %keywordwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_KEYWORD, msg)) %enddef
%define %builtinwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, msg)) %enddef
#define %keywordwarn(msg...) %namewarn(%warningmsg(SWIGWARN_PARSE_KEYWORD, msg))
#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);
Preprocessor_define(value,1);
}
StringPutc('\n',ns);
/* StringPutc('\n',ns);*/
addline(ns,value,0);
state = 0;
}