Raw string literal changes in paper N3077 changes delimiters to use round brackets instead of square brackets

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12152 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-06-25 22:54:45 +00:00
commit adffcd60e1
4 changed files with 83 additions and 39 deletions

View file

@ -8,14 +8,16 @@
This module also tests whether Swig correctly parses custom string delimiters.
*/
%module cpp0x_raw_string_literals
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) aa;
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) bb;
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) ee;
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) ff;
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) gg;
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) xx;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) dd;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) gg;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) hh;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ii;
%include <std_wstring.i>
%inline %{
#include <iostream>
@ -38,27 +40,20 @@ struct URStruct {
static const int UR = 100;
};
const char *aa = "ABC";
wstring wide = L"ABC";
const char *bb = u8"ABC";
const char16_t *cc = u"ABC";
const char32_t *dd = U"ABC";
// New string literals
wstring aa = L"Wide string";
const char *bb = u8"UTF-8 string";
const char16_t *cc = u"UTF-16 string";
const char32_t *dd = U"UTF-32 string";
%}
/* Raw string literals */
#warning TODO: change SWIG support from old R"[ ... ]" to new R"( ... )"
const char *ee = R"XXX[to be or "not" to be [square parenthesis] (round parenthesis), that is the question!]XXX";
wstring wide2 = LR"XXX[to be or "not" to be [square parenthesis] (round parenthesis), that is the question!]XXX";
const char *ff = u8R"XXX[to be or "not" to be [square parenthesis] (round parenthesis), that is the question!]XXX";
const char16_t *gg = uR"XXX[to be or "not" to be [square parenthesis] (round parenthesis), that is the question!]XXX";
const char32_t *hh = UR"XXX[to be or "not" to be [square parenthesis] (round parenthesis), that is the question!]XXX";
%{
const char *ee = R"XXX(to be or "not" to be [square parenthesis] (round parenthesis), that is the question!)XXX";
wstring wide2 = LR"XXX(to be or "not" to be [square parenthesis] (round parenthesis), that is the question!)XXX";
const char *ff = u8R"XXX(to be or "not" to be [square parenthesis] (round parenthesis), that is the question!)XXX";
const char16_t *gg = uR"XXX(to be or "not" to be [square parenthesis] (round parenthesis), that is the question!)XXX";
const char32_t *hh = UR"XXX(to be or "not" to be [square parenthesis] (round parenthesis), that is the question!)XXX";
%inline %{
const char *xx = ")I'm an \"ascii\" \\ string.";
const char *ee = R"XXX()I'm an "ascii" \ string.)XXX";
wstring ff = LR"XXX(I'm a "raw wide" \ string.)XXX";
const char *gg = u8R"XXX(I'm a "raw UTF-8" \ string.)XXX";
const char16_t *hh = uR"XXX(I'm a "raw UTF-16" \ string.)XXX";
const char32_t *ii = UR"XXX(I'm a "raw UTF-32" \ string.)XXX";
%}

View file

@ -0,0 +1,50 @@
from cpp0x_raw_string_literals import *
if cvar.L != 100:
raise RuntimeError
if cvar.u8 != 100:
raise RuntimeError
if cvar.u != 100:
raise RuntimeError
if UStruct.U != 100:
raise RuntimeError
if cvar.R != 100:
raise RuntimeError
if cvar.LR != 100:
raise RuntimeError
if cvar.u8R != 100:
raise RuntimeError
if cvar.uR != 100:
raise RuntimeError
if URStruct.UR != 100:
raise RuntimeError
if cvar.aa != "Wide string":
raise RuntimeError
if cvar.bb != "UTF-8 string":
raise RuntimeError, cvar.wide
if cvar.xx != ")I'm an \"ascii\" \\ string.":
raise RuntimeError, cvar.xx
if cvar.ee != ")I'm an \"ascii\" \\ string.":
raise RuntimeError, cvar.ee
if cvar.ff != "I'm a \"raw wide\" \\ string.":
raise RuntimeError, cvar.ff
if cvar.gg != "I'm a \"raw UTF-8\" \\ string.":
raise RuntimeError, cvar.gg