diff options
author | Jan Jezabek <jezabek@poczta.onet.pl> | 2008-09-16 17:34:45 +0000 |
---|---|---|
committer | Jan Jezabek <jezabek@poczta.onet.pl> | 2008-09-16 17:34:45 +0000 |
commit | 640282ec9bb37aae87724b6403f456aece182eb9 (patch) | |
tree | 80aa27cc2addeb8d3ea693f3d75493ecb5fa6a47 | |
parent | 5d4de6e1a15d559227688934a9a67b1d6dc96674 (diff) | |
download | swig-640282ec9bb37aae87724b6403f456aece182eb9.tar.gz |
Changed mapping of bool (VARIANT_BOOL instead of int). This is required for VB and accepted by other COM-aware languages.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-jezabek@10858 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r-- | Examples/test-suite/com/char_strings_runme.vbs | 14 | ||||
-rw-r--r-- | Lib/com/com.swg | 16 | ||||
-rw-r--r-- | Lib/com/typemaps.i | 16 |
3 files changed, 25 insertions, 21 deletions
diff --git a/Examples/test-suite/com/char_strings_runme.vbs b/Examples/test-suite/com/char_strings_runme.vbs index ba9287f87..0070697db 100644 --- a/Examples/test-suite/com/char_strings_runme.vbs +++ b/Examples/test-suite/com/char_strings_runme.vbs @@ -55,42 +55,42 @@ Next Rem set functions For i = 0 to count - 1 - If char_strings.SetCharHeapString(OTHERLAND_MSG & i, i) = 0 Then + If Not char_strings.SetCharHeapString(OTHERLAND_MSG & i, i) Then WScript.Echo "Test char set 1 failed, iteration " & i WScript.Quit 1 End If Next For i = 0 to count - 1 - If char_strings.SetCharStaticString(OTHERLAND_MSG & i, i) = 0 Then + If Not char_strings.SetCharStaticString(OTHERLAND_MSG & i, i) Then WScript.Echo "Test char set 2 failed, iteration " & i WScript.Quit 1 End If Next For i = 0 to count - 1 - If char_strings.SetCharArrayStaticString(OTHERLAND_MSG & i, i) = 0 Then + If Not char_strings.SetCharArrayStaticString(OTHERLAND_MSG & i, i) Then WScript.Echo "Test char set 3 failed, iteration " & i WScript.Quit 1 End If Next For i = 0 to count - 1 - If char_strings.SetConstCharHeapString(OTHERLAND_MSG & i, i) = 0 Then + If Not char_strings.SetConstCharHeapString(OTHERLAND_MSG & i, i) Then WScript.Echo "Test char set 4 failed, iteration " & i WScript.Quit 1 End If Next For i = 0 to count - 1 - If char_strings.SetConstCharStaticString(OTHERLAND_MSG & i, i) = 0 Then + If Not char_strings.SetConstCharStaticString(OTHERLAND_MSG & i, i) Then WScript.Echo "Test char set 5 failed, iteration " & i WScript.Quit 1 End If Next For i = 0 to count - 1 - If char_strings.SetConstCharArrayStaticString(OTHERLAND_MSG & i, i) = 0 Then + If Not char_strings.SetConstCharArrayStaticString(OTHERLAND_MSG & i, i) Then WScript.Echo "Test char set 6 failed, iteration " & i WScript.Quit 1 End If @@ -167,7 +167,7 @@ For i = 0 to count - 1 Next For i = 0 to count - 1 - If char_strings.SetConstCharPointerRef(OTHERLAND_MSG & i, i) = 0 Then + If Not char_strings.SetConstCharPointerRef(OTHERLAND_MSG & i, i) Then WScript.Echo "Test char pointer ref set failed, iteration " & i WScript.Quit 1 End If diff --git a/Lib/com/com.swg b/Lib/com/com.swg index 59b0b1917..afcb72ab9 100644 --- a/Lib/com/com.swg +++ b/Lib/com/com.swg @@ -7,7 +7,7 @@ * COM typemaps * ----------------------------------------------------------------------------- */ -%typemap(ctype) bool, const bool & "int" +%typemap(ctype) bool, const bool & "VARIANT_BOOL" %typemap(ctype) char, const char & "char" %typemap(ctype) signed char, const signed char & "signed char" %typemap(ctype) unsigned char, const unsigned char & "unsigned char" @@ -28,7 +28,7 @@ %typemap(ctype) SWIGTYPE & "SWIGIUnknown *" %typemap(ctype) enum SWIGTYPE "int" -%typemap(comtype) bool, const bool & "int" +%typemap(comtype) bool, const bool & "VARIANT_BOOL" %typemap(comtype) char, const char & "char" %typemap(comtype) signed char, const signed char & "signed char" %typemap(comtype) unsigned char, const unsigned char & "unsigned char" @@ -157,8 +157,10 @@ %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %} -%typemap(out) bool, - char, +%typemap(out) bool +%{ $result = $1 ? VARIANT_TRUE : VARIANT_FALSE; %} + +%typemap(out) char, signed char, unsigned char, short, @@ -173,8 +175,10 @@ double %{ $result = $1; %} -%typemap(out) const bool &, - const char &, +%typemap(out) const bool & +%{ $result = *$1 ? VARIANT_TRUE : VARIANT_FALSE; %} + +%typemap(out) const char &, const signed char &, const unsigned char &, const short &, diff --git a/Lib/com/typemaps.i b/Lib/com/typemaps.i index 4ff9d512f..0676797b4 100644 --- a/Lib/com/typemaps.i +++ b/Lib/com/typemaps.i @@ -9,7 +9,7 @@ /* INPUT typemaps */ -%typemap(ctype) bool *INPUT, bool &INPUT "int *" +%typemap(ctype) bool *INPUT, bool &INPUT "VARIANT_BOOL *" %typemap(ctype) signed char *INPUT, signed char &INPUT "signed char *" %typemap(ctype) unsigned char *INPUT, unsigned char &INPUT "unsigned char *" %typemap(ctype) short *INPUT, short &INPUT "short *" @@ -23,7 +23,7 @@ %typemap(ctype) float *INPUT, float &INPUT "float *" %typemap(ctype) double *INPUT, double &INPUT "double *" -%typemap(comtype, attribute="in") bool *INPUT, bool &INPUT "int *" +%typemap(comtype, attribute="in") bool *INPUT, bool &INPUT "VARIANT_BOOL *" %typemap(comtype, attribute="in") signed char *INPUT, signed char &INPUT "signed char *" %typemap(comtype, attribute="in") unsigned char *INPUT, unsigned char &INPUT "unsigned char *" %typemap(comtype, attribute="in") short *INPUT, short &INPUT "short *" @@ -85,7 +85,7 @@ /* OUTPUT typemaps */ -%typemap(ctype) bool *OUTPUT, bool &OUTPUT "int *" +%typemap(ctype) bool *OUTPUT, bool &OUTPUT "VARIANT_BOOL *" %typemap(ctype) signed char *OUTPUT, signed char &OUTPUT "signed char *" %typemap(ctype) unsigned char *OUTPUT, unsigned char &OUTPUT "unsigned char *" %typemap(ctype) short *OUTPUT, short &OUTPUT "short *" @@ -99,7 +99,7 @@ %typemap(ctype) float *OUTPUT, float &OUTPUT "float *" %typemap(ctype) double *OUTPUT, double &OUTPUT "double *" -%typemap(comtype, attribute="out") bool *OUTPUT, bool &OUTPUT "int *" +%typemap(comtype, attribute="out") bool *OUTPUT, bool &OUTPUT "VARIANT_BOOL *" %typemap(comtype, attribute="out") signed char *OUTPUT, signed char &OUTPUT "signed char *" %typemap(comtype, attribute="out") unsigned char *OUTPUT, unsigned char &OUTPUT "unsigned char *" %typemap(comtype, attribute="out") short *OUTPUT, short &OUTPUT "short *" @@ -146,7 +146,7 @@ double *OUTPUT, double &OUTPUT "" %typemap(argout) bool *OUTPUT, bool &OUTPUT -%{ *$input = temp$argnum ? 1 : 0; %} +%{ *$input = temp$argnum ? VARIANT_TRUE : VARIANT_FALSE; %} %typemap(argout) signed char *OUTPUT, signed char &OUTPUT, unsigned char *OUTPUT, unsigned char &OUTPUT, @@ -163,7 +163,7 @@ /* INOUT typemaps */ -%typemap(ctype) bool *INOUT, bool &INOUT "int *" +%typemap(ctype) bool *INOUT, bool &INOUT "VARIANT_BOOL *" %typemap(ctype) signed char *INOUT, signed char &INOUT "signed char *" %typemap(ctype) unsigned char *INOUT, unsigned char &INOUT "unsigned char *" %typemap(ctype) short *INOUT, short &INOUT "short *" @@ -177,7 +177,7 @@ %typemap(ctype) float *INOUT, float &INOUT "float *" %typemap(ctype) double *INOUT, double &INOUT "double *" -%typemap(comtype, attribute="in, out") bool *INOUT, bool &INOUT "int *" +%typemap(comtype, attribute="in, out") bool *INOUT, bool &INOUT "VARIANT_BOOL *" %typemap(comtype, attribute="in, out") signed char *INOUT, signed char &INOUT "signed char *" %typemap(comtype, attribute="in, out") unsigned char *INOUT, unsigned char &INOUT "unsigned char *" %typemap(comtype, attribute="in, out") short *INOUT, short &INOUT "short *" @@ -224,7 +224,7 @@ double *INOUT, double &INOUT "" %typemap(argout) bool *INOUT, bool &INOUT -%{ *$input = temp$argnum ? 1 : 0; %} +%{ *$input = temp$argnum ? VARIANT_TRUE : VARIANT_FALSE; %} %typemap(argout) signed char *INOUT, signed char &INOUT, unsigned char *INOUT, unsigned char &INOUT, |