From: <wsf...@us...> - 2012-04-23 22:15:43
|
Revision: 13013 http://swig.svn.sourceforge.net/swig/?rev=13013&view=rev Author: wsfulton Date: 2012-04-23 22:15:37 +0000 (Mon, 23 Apr 2012) Log Message: ----------- Using C++11 enum classes with just a forward reference. Modified Paths: -------------- branches/gsoc2009-matevz/Examples/test-suite/cpp0x_strongly_typed_enumerations.i branches/gsoc2009-matevz/Lib/csharp/enums.swg branches/gsoc2009-matevz/Lib/csharp/enumsimple.swg branches/gsoc2009-matevz/Lib/csharp/enumtypesafe.swg branches/gsoc2009-matevz/Lib/php/php.swg Modified: branches/gsoc2009-matevz/Examples/test-suite/cpp0x_strongly_typed_enumerations.i =================================================================== --- branches/gsoc2009-matevz/Examples/test-suite/cpp0x_strongly_typed_enumerations.i 2012-04-21 10:06:43 UTC (rev 13012) +++ branches/gsoc2009-matevz/Examples/test-suite/cpp0x_strongly_typed_enumerations.i 2012-04-23 22:15:37 UTC (rev 13013) @@ -67,6 +67,12 @@ Val1, Val2, Val3 = 300, Val4 }; +// forward declaration, no definition of enum +enum class Enum11 : int; +struct UseEnum11 { + Enum11 myenum11; +}; + /* TODO enum class MyClass {AAA, BBB, CCC}; Modified: branches/gsoc2009-matevz/Lib/csharp/enums.swg =================================================================== --- branches/gsoc2009-matevz/Lib/csharp/enums.swg 2012-04-21 10:06:43 UTC (rev 13012) +++ branches/gsoc2009-matevz/Lib/csharp/enums.swg 2012-04-23 22:15:37 UTC (rev 13013) @@ -13,12 +13,12 @@ %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} -%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %} +%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" +%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" %typemap(csdirectorin) const enum SWIGTYPE & "($*csclassname)$iminput" %typemap(csdirectorout) const enum SWIGTYPE & "(int)$cscall" @@ -48,10 +48,10 @@ %typemap(cstype) enum SWIGTYPE "$csclassname" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} -%typemap(out) enum SWIGTYPE %{ $result = $1; %} +%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} -%typemap(directorin) enum SWIGTYPE "$input = $1;" +%typemap(directorin) enum SWIGTYPE "$input = $1;" %typemap(csdirectorin) enum SWIGTYPE "($csclassname)$iminput" %typemap(csdirectorout) enum SWIGTYPE "(int)$cscall" Modified: branches/gsoc2009-matevz/Lib/csharp/enumsimple.swg =================================================================== --- branches/gsoc2009-matevz/Lib/csharp/enumsimple.swg 2012-04-21 10:06:43 UTC (rev 13012) +++ branches/gsoc2009-matevz/Lib/csharp/enumsimple.swg 2012-04-23 22:15:37 UTC (rev 13013) @@ -15,12 +15,12 @@ %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} -%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %} +%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" +%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" %typemap(csdirectorin) const enum SWIGTYPE & "$iminput" %typemap(csdirectorout) const enum SWIGTYPE & "$cscall" @@ -50,10 +50,10 @@ %typemap(cstype) enum SWIGTYPE "int" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} -%typemap(out) enum SWIGTYPE %{ $result = $1; %} +%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} -%typemap(directorin) enum SWIGTYPE "$input = $1;" +%typemap(directorin) enum SWIGTYPE "$input = $1;" %typemap(csdirectorin) enum SWIGTYPE "$iminput" %typemap(csdirectorout) enum SWIGTYPE "$cscall" Modified: branches/gsoc2009-matevz/Lib/csharp/enumtypesafe.swg =================================================================== --- branches/gsoc2009-matevz/Lib/csharp/enumtypesafe.swg 2012-04-21 10:06:43 UTC (rev 13012) +++ branches/gsoc2009-matevz/Lib/csharp/enumtypesafe.swg 2012-04-23 22:15:37 UTC (rev 13013) @@ -14,12 +14,12 @@ %typemap(in) const enum SWIGTYPE & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; $1 = &temp; %} -%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %} +%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE & %{ static $*1_ltype temp = ($*1_ltype)$input; $result = &temp; %} -%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" +%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;" %typemap(csdirectorin) const enum SWIGTYPE & "$*csclassname.swigToEnum($iminput)" %typemap(csdirectorout) const enum SWIGTYPE & "$cscall.swigValue" @@ -49,10 +49,10 @@ %typemap(cstype) enum SWIGTYPE "$csclassname" %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} -%typemap(out) enum SWIGTYPE %{ $result = $1; %} +%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %} %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %} -%typemap(directorin) enum SWIGTYPE "$input = $1;" +%typemap(directorin) enum SWIGTYPE "$input = $1;" %typemap(csdirectorin) enum SWIGTYPE "$csclassname.swigToEnum($iminput)" %typemap(csdirectorout) enum SWIGTYPE "$cscall.swigValue" Modified: branches/gsoc2009-matevz/Lib/php/php.swg =================================================================== --- branches/gsoc2009-matevz/Lib/php/php.swg 2012-04-21 10:06:43 UTC (rev 13012) +++ branches/gsoc2009-matevz/Lib/php/php.swg 2012-04-23 22:15:37 UTC (rev 13013) @@ -189,12 +189,16 @@ signed char, unsigned char, bool, - size_t, - enum SWIGTYPE + size_t { ZVAL_LONG(return_value,$1); } +%typemap(out) enum SWIGTYPE +{ + ZVAL_LONG(return_value, (long)$1); +} + %typemap(out) long long %{ if ((long long)LONG_MIN <= $1 && $1 <= (long long)LONG_MAX) { @@ -227,12 +231,16 @@ const signed char &, const unsigned char &, const bool &, - const size_t &, - const enum SWIGTYPE & + const size_t & { ZVAL_LONG(return_value,*$1); } +%typemap(out) const enum SWIGTYPE & +{ + ZVAL_LONG(return_value, (long)*$1); +} + %typemap(out) const long long & %{ if ((long long)LONG_MIN <= *$1 && *$1 <= (long long)LONG_MAX) { @@ -270,6 +278,11 @@ ZVAL_LONG($input,$1_name); } +%typemap(directorin) enum SWIGTYPE +{ + ZVAL_LONG($input, (long)$1_name); +} + %typemap(out) bool { ZVAL_BOOL(return_value,($1)?1:0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |