Merge branch 'char-escaping'

* char-escaping:
  Add missing string_constant.i testcase
  changes file update for char wrappers
  C# char wrappers fixes for enum values, static const member char values and %csconst
  D testing added for %dmanifestconst and char constants
  Fix wrapping D constants using %dmanifestconst
  Php fix for enum value of '\0'
  Fix static const char member variables wrappers with %javaconst(1).
  Expand char testing in enums and %constant
  Java char changes file update
  Java enum and static member variable escaping fix for chars
  Add tests for enum values and static const member variables chars containing escape sequences
  Minor documentation tweak

Conflicts:
	CHANGES.current
This commit is contained in:
William S Fulton 2016-03-12 23:27:51 +00:00
commit ac495d5c66
15 changed files with 355 additions and 23 deletions

View file

@ -12,6 +12,36 @@
#define ESC_CONST '\1'
#define NULL_CONST '\0'
#define SPECIALCHAR 'á'
#define SPECIALCHAR2 '\n'
#define SPECIALCHARA 'A'
#define SPECIALCHARB '\102' // B
#define SPECIALCHARC '\x43' // C
#define SPECIALCHARD 0x44 // D
#define SPECIALCHARE 69 // E
#define SPECIALCHARAE1 'Æ' // AE (latin1 encoded)
#define SPECIALCHARAE2 '\306' // AE (latin1 encoded)
#define SPECIALCHARAE3 '\xC6' // AE (latin1 encoded)
#if defined(SWIGJAVA)
%javaconst(1);
#elif SWIGCSHARP
%csconst(1);
#elif SWIGD
%dmanifestconst;
#endif
#define X_ESC_CONST '\1'
#define X_NULL_CONST '\0'
#define X_SPECIALCHAR 'á'
#define X_SPECIALCHAR2 '\n'
#define X_SPECIALCHARA 'A'
#define X_SPECIALCHARB '\102' // B
#define X_SPECIALCHARC '\x43' // C
#define X_SPECIALCHARD 0x44 // D
#define X_SPECIALCHARE 69 // E
#define X_SPECIALCHARAE1 'Æ' // AE (latin1 encoded)
#define X_SPECIALCHARAE2 '\306' // AE (latin1 encoded)
#define X_SPECIALCHARAE3 '\xC6' // AE (latin1 encoded)
%inline
{

View file

@ -12,4 +12,65 @@ char GetUnprintableChar() {
return 0x7F;
}
static const char globchar0 = '\0';
static const char globchar1 = '\1';
static const char globchar2 = '\n';
static const char globcharA = 'A';
static const char globcharB = '\102'; // B
static const char globcharC = '\x43'; // C
static const char globcharD = 0x44; // D
static const char globcharE = 69; // E
static const char globcharAE1 = 'Æ'; // AE (latin1 encoded)
static const char globcharAE2 = '\306'; // AE (latin1 encoded)
static const char globcharAE3 = '\xC6'; // AE (latin1 encoded)
struct CharTestClass {
static const char memberchar0 = '\0';
static const char memberchar1 = '\1';
static const char memberchar2 = '\n';
static const char membercharA = 'A';
static const char membercharB = '\102'; // B
static const char membercharC = '\x43'; // C
static const char membercharD = 0x44; // D
static const char membercharE = 69; // E
static const char membercharAE1 = 'Æ'; // AE (latin1 encoded)
static const char membercharAE2 = '\306'; // AE (latin1 encoded)
static const char membercharAE3 = '\xC6'; // AE (latin1 encoded)
};
%}
#if defined(SWIGJAVA)
%javaconst(1);
#elif SWIGCSHARP
%csconst(1);
#elif SWIGD
%dmanifestconst;
#endif
%inline %{
static const char x_globchar0 = '\0';
static const char x_globchar1 = '\1';
static const char x_globchar2 = '\n';
static const char x_globcharA = 'A';
static const char x_globcharB = '\102'; // B
static const char x_globcharC = '\x43'; // C
static const char x_globcharD = 0x44; // D
static const char x_globcharE = 69; // E
static const char x_globcharAE1 = 'Æ'; // AE (latin1 encoded)
static const char x_globcharAE2 = '\306'; // AE (latin1 encoded)
static const char x_globcharAE3 = '\xC6'; // AE (latin1 encoded)
struct X_CharTestClass {
static const char memberchar0 = '\0';
static const char memberchar1 = '\1';
static const char memberchar2 = '\n';
static const char membercharA = 'A';
static const char membercharB = '\102'; // B
static const char membercharC = '\x43'; // C
static const char membercharD = 0x44; // D
static const char membercharE = 69; // E
static const char membercharAE1 = 'Æ'; // AE (latin1 encoded)
static const char membercharAE2 = '\306'; // AE (latin1 encoded)
static const char membercharAE3 = '\xC6'; // AE (latin1 encoded)
};
%}

View file

@ -384,6 +384,7 @@ CPP_TEST_CASES += \
static_array_member \
static_const_member \
static_const_member_2 \
string_constants \
struct_initialization_cpp \
struct_value \
symbol_clash \

View file

@ -77,6 +77,10 @@
// char
char chartest1(char c = 'x') { return c; }
char chartest2(char c = '\0') { return c; }
char chartest3(char c = '\1') { return c; }
char chartest4(char c = '\n') { return c; }
char chartest5(char c = '\102') { return c; } // 'B'
char chartest6(char c = '\x43') { return c; } // 'C'
// namespaces
namespace AType {

View file

@ -585,7 +585,56 @@ enum {
};
int globalDifferentTypesTest(int n) { return n; }
}
%}
#if defined(SWIGCSHARP)
%csconstvalue("1") globalenumchar1;
%csconstvalue("'B'") globalenumcharB;
%csconstvalue("1") enumchar1;
%csconstvalue("'B'") enumcharB;
#endif
%inline %{
enum {
globalenumchar0 = '\0',
globalenumchar1 = '\1',
globalenumchar2 = '\n',
globalenumcharA = 'A',
globalenumcharB = '\102', // B
globalenumcharC = '\x43', // C
globalenumcharD = 0x44, // D
globalenumcharE = 69, // E
globalenumcharAE1 = 'Æ', // AE (latin1 encoded)
globalenumcharAE2 = '\306', // AE (latin1 encoded)
globalenumcharAE3 = '\xC6' // AE (latin1 encoded)
};
enum EnumChar {
enumchar0 = '\0',
enumchar1 = '\1',
enumchar2 = '\n',
enumcharA = 'A',
enumcharB = '\102', // B
enumcharC = '\x43', // C
enumcharD = 0x44, // D
enumcharE = 69, // E
enumcharAE1 = 'Æ', // AE (latin1 encoded)
enumcharAE2 = '\306', // AE (latin1 encoded)
enumcharAE3 = '\xC6' // AE (latin1 encoded)
};
struct EnumCharStruct {
enum EnumChar {
enumchar0 = '\0',
enumchar1 = '\1',
enumchar2 = '\n',
enumcharA = 'A',
enumcharB = '\102', // B
enumcharC = '\x43', // C
enumcharD = 0x44, // D
enumcharE = 69, // E
enumcharAE1 = 'Æ', // AE (latin1 encoded)
enumcharAE2 = '\306', // AE (latin1 encoded)
enumcharAE3 = '\xC6' // AE (latin1 encoded)
};
};
%}
#if defined(SWIGJAVA)
@ -594,6 +643,50 @@ int globalDifferentTypesTest(int n) { return n; }
%csconst(0);
#endif
%inline %{
enum {
x_globalenumchar0 = '\0',
x_globalenumchar1 = '\1',
x_globalenumchar2 = '\n',
x_globalenumcharA = 'A',
x_globalenumcharB = '\102', // B
x_globalenumcharC = '\x43', // C
x_globalenumcharD = 0x44, // D
x_globalenumcharE = 69, // E
x_globalenumcharAE1 = 'Æ', // AE (latin1 encoded)
x_globalenumcharAE2 = '\306', // AE (latin1 encoded)
x_globalenumcharAE3 = '\xC6' // AE (latin1 encoded)
};
enum X_EnumChar {
x_enumchar0 = '\0',
x_enumchar1 = '\1',
x_enumchar2 = '\n',
x_enumcharA = 'A',
x_enumcharB = '\102', // B
x_enumcharC = '\x43', // C
x_enumcharD = 0x44, // D
x_enumcharE = 69, // E
x_enumcharAE1 = 'Æ', // AE (latin1 encoded)
x_enumcharAE2 = '\306', // AE (latin1 encoded)
x_enumcharAE3 = '\xC6' // AE (latin1 encoded)
};
struct X_EnumCharStruct {
enum X_EnumChar {
enumchar0 = '\0',
enumchar1 = '\1',
enumchar2 = '\n',
enumcharA = 'A',
enumcharB = '\102', // B
enumcharC = '\x43', // C
enumcharD = 0x44, // D
enumcharE = 69, // E
enumcharAE1 = 'Æ', // AE (latin1 encoded)
enumcharAE2 = '\306', // AE (latin1 encoded)
enumcharAE3 = '\xC6' // AE (latin1 encoded)
};
};
%}
%inline %{
namespace DifferentSpace {
enum DifferentTypesNoConst {
@ -614,5 +707,4 @@ enum {
global_typedefaultint_noconst
};
}
%}

View file

@ -136,5 +136,23 @@ def run(module_name):
if default_args.CDA().cdefaultargs_test2() != 1:
raise RuntimeError
if default_args.chartest1() != 'x':
raise RuntimeError
if default_args.chartest2() != '\0':
raise RuntimeError
if default_args.chartest3() != '\1':
raise RuntimeError
if default_args.chartest4() != '\n':
raise RuntimeError
if default_args.chartest5() != 'B':
raise RuntimeError
if default_args.chartest6() != 'C':
raise RuntimeError
if __name__ == "__main__":
run('default_args')

View file

@ -0,0 +1,44 @@
%module string_constants
// Test unusual string constants
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK);
#if defined(SWIGCSHARP)
%csconst(1);
%csconstvalue("\"AEIOU\\n\"") SS1;
%csconstvalue("\"AEIOU\\n\"") SS2;
#endif
#if defined(SWIGJAVA)
%javaconst(1);
#endif
%inline %{
#define SS1 "ÆÎOU\n"
#define AA1 "A\rB\nC"
#define EE1 "\124\125\126"
#define XX1 "\x57\x58\x59"
#define ZS1 "\0"
#define ES1 ""
%}
%constant SS2="ÆÎOU\n";
%constant AA2="A\rB\nC";
%constant EE2="\124\125\126";
%constant XX2="\x57\x58\x59";
%constant ZS2="\0";
%constant ES2="";
%inline %{
static const char *SS3 = "ÆÎOU\n";
static const char *AA3 = "A\rB\nC";
static const char *EE3 = "\124\125\126";
static const char *XX3 = "\x57\x58\x59";
static const char *ZS3 = "\0";
static const char *ES3 = "";
struct things {
const char * defarguments1(const char *SS4 = "ÆÎOU\n") { return SS4; }
const char * defarguments2(const char *AA4 = "A\rB\nC") { return AA4; }
const char * defarguments3(const char *EE4 = "\124\125\126") { return EE4; }
const char * defarguments4(const char *XX4 = "\x57\x58\x59") { return XX4; }
const char * defarguments5(const char *ZS4 = "\0") { return ZS4; }
const char * defarguments6(const char *ES4 = "") { return ES4; }
};
%}