Merge remote-tracking branch 'origin/master' into gsoc2012-scilab

This commit is contained in:
Sylvestre Ledru 2013-09-13 10:03:56 +02:00
commit 228b7d9a6c

View file

@ -23,29 +23,29 @@
SWIG provides the following casting macros, which implement the SWIG provides the following casting macros, which implement the
corresponding C++ casting operations: corresponding C++ casting operations:
%const_cast(a, Type) const_cast<Type >(a) %const_cast(a, Type) const_cast<Type >(a)
%static_cast(a, Type) static_cast<Type >(a) %static_cast(a, Type) static_cast<Type >(a)
%reinterpret_cast(a, Type) reinterpret_cast<Type >(a) %reinterpret_cast(a, Type) reinterpret_cast<Type >(a)
%numeric_cast(a, Type) static_cast<Type >(a) %numeric_cast(a, Type) static_cast<Type >(a)
%as_voidptr(a) const_cast<void *>(static_cast<const void *>(a)) %as_voidptr(a) const_cast<void *>(static_cast<const void *>(a))
%as_voidptrptr(a) reinterpret_cast<void **>(a) %as_voidptrptr(a) reinterpret_cast<void **>(a)
or their C unsafe versions. In C++ we use the safe version unless or their C unsafe versions. In C++ we use the safe version unless
SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag). SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag).
Memory allocation: Memory allocation:
------------------ ------------------
These allocation/freeing macros are safe to use in C or C++ and These allocation/freeing macros are safe to use in C or C++ and
dispatch the proper new/delete/delete[] or free/malloc calls as dispatch the proper new/delete/delete[] or free/malloc calls as
needed. needed.
%new_instance(Type) Allocate a new instance of given Type %new_instance(Type) Allocate a new instance of given Type
%new_copy(value,Type) Allocate and initialize a new instance with 'value' %new_copy(value,Type) Allocate and initialize a new instance with 'value'
%new_array(size,Type) Allocate a new array with given size and Type %new_array(size,Type) Allocate a new array with given size and Type
%new_copy_array(cptr,size,Type) Allocate and initialize a new array from 'cptr' %new_copy_array(cptr,size,Type) Allocate and initialize a new array from 'cptr'
%delete(cptr) Delete an instance %delete(cptr) Delete an instance
%delete_array(cptr) Delete an array %delete_array(cptr) Delete an array
@ -54,13 +54,13 @@
%formacro(Macro, Args...) or %formacro_1(Macro, Args...) %formacro(Macro, Args...) or %formacro_1(Macro, Args...)
for i in Args for i in Args
do do
Macro($i) Macro($i)
done done
%formacro_2(Macro2, Args...) %formacro_2(Macro2, Args...)
for i,j in Args for i,j in Args
do do
Macro2($i, $j) Macro2($i, $j)
done done
@ -71,12 +71,12 @@
%mark_flag(flag) %mark_flag(flag)
flag := True flag := True
%evalif(flag,expr) %evalif(flag,expr)
if flag; then if flag; then
expr expr
fi fi
%evalif_2(flag1 flag2,expr) %evalif_2(flag1 flag2,expr)
if flag1 and flag2; then if flag1 and flag2; then
expr expr
fi fi
@ -84,7 +84,7 @@
*/ */
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Basic preprocessor macros * Basic preprocessor macros
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
#define %arg(Arg...) Arg #define %arg(Arg...) Arg
@ -115,7 +115,7 @@ nocppval
%define_as(SWIGVERSION, SWIG_VERSION) %define_as(SWIGVERSION, SWIG_VERSION)
%#define SWIG_VERSION SWIGVERSION %#define SWIG_VERSION SWIGVERSION
} }
#endif #endif
@ -153,10 +153,10 @@ nocppval
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Allocating/freeing elements * Allocating/freeing elements
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
#if defined(__cplusplus) #if defined(__cplusplus)
# define %new_instance(Type...) (new Type) # define %new_instance(Type...) (new Type)
# define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&))) # define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&)))
# define %new_array(size,Type...) (new Type[size]) # define %new_array(size,Type...) (new Type[size])
@ -184,7 +184,7 @@ nocppval
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Auxiliary loop macros * Auxiliary loop macros
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
@ -213,10 +213,10 @@ nocppval
* SWIG flags * SWIG flags
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
/* /*
mark a flag, ie, define a macro name but ignore it in mark a flag, ie, define a macro name but ignore it in
the interface. the interface.
the flag can be later used with %evalif the flag can be later used with %evalif
*/ */
@ -224,16 +224,16 @@ nocppval
/* /*
%evalif and %evalif_2 are use to evaluate or process %evalif and %evalif_2 are use to evaluate or process
an expression if the given predicate is 'true' (1). an expression if the given predicate is 'true' (1).
*/ */
%define %_evalif(_x,_expr) %define %_evalif(_x,_expr)
#if _x == 1 #if _x == 1
_expr _expr
#endif #endif
%enddef %enddef
%define %_evalif_2(_x,_y,_expr) %define %_evalif_2(_x,_y,_expr)
#if _x == 1 && _y == 1 #if _x == 1 && _y == 1
_expr _expr
#endif #endif