[pypy-commit] pypy cling-support: coding convention and prepare for more test
wlav
pypy.commits at gmail.com
Wed Nov 23 16:34:02 EST 2016
Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: cling-support
Changeset: r88595:cf4a6dabef21
Date: 2016-11-23 13:26 -0800
http://bitbucket.org/pypy/pypy/changeset/cf4a6dabef21/
Log: coding convention and prepare for more test
diff --git a/pypy/module/cppyy/test/datatypes.cxx b/pypy/module/cppyy/test/datatypes.cxx
--- a/pypy/module/cppyy/test/datatypes.cxx
+++ b/pypy/module/cppyy/test/datatypes.cxx
@@ -2,23 +2,31 @@
//===========================================================================
-cppyy_test_data::cppyy_test_data() : m_owns_arrays(false)
+std::vector<EFruit> vecFruits{kCitrus, kApple};
+
+
+//===========================================================================
+CppyyTestData::CppyyTestData() : m_owns_arrays(false)
{
- m_bool = false;
- m_char = 'a';
- m_uchar = 'c';
- m_short = -11;
- m_ushort = 11u;
- m_int = -22;
- m_uint = 22u;
- m_long = -33l;
- m_ulong = 33ul;
- m_llong = -44ll;
- m_ullong = 55ull;
- m_float = -66.f;
- m_double = -77.;
- m_enum = kNothing;
- m_voidp = (void*)0;
+ m_bool = false;
+ m_char = 'a';
+ m_schar = 'b';
+ m_uchar = 'c';
+ m_short = -11;
+ m_ushort = 11u;
+ m_int = -22;
+ m_uint = 22u;
+ m_long = -33l;
+ m_ulong = 33ul;
+ m_llong = -44ll;
+ m_ullong = 44ull;
+ m_long64 = -55ll;
+ m_ulong64 = 55ull;
+ m_float = -66.f;
+ m_double = -77.;
+ m_ldouble = -88.l;
+ m_enum = kNothing;
+ m_voidp = (void*)0;
m_bool_array2 = new bool[N];
m_short_array2 = new short[N];
@@ -61,12 +69,12 @@
m_ppod = &m_pod;
};
-cppyy_test_data::~cppyy_test_data()
+CppyyTestData::~CppyyTestData()
{
destroy_arrays();
}
-void cppyy_test_data::destroy_arrays() {
+void CppyyTestData::destroy_arrays() {
if (m_owns_arrays == true) {
delete[] m_bool_array2;
delete[] m_short_array2;
@@ -84,159 +92,244 @@
}
//- getters -----------------------------------------------------------------
-bool cppyy_test_data::get_bool() { return m_bool; }
-char cppyy_test_data::get_char() { return m_char; }
-unsigned char cppyy_test_data::get_uchar() { return m_uchar; }
-short cppyy_test_data::get_short() { return m_short; }
-unsigned short cppyy_test_data::get_ushort() { return m_ushort; }
-int cppyy_test_data::get_int() { return m_int; }
-unsigned int cppyy_test_data::get_uint() { return m_uint; }
-long cppyy_test_data::get_long() { return m_long; }
-unsigned long cppyy_test_data::get_ulong() { return m_ulong; }
-long long cppyy_test_data::get_llong() { return m_llong; }
-unsigned long long cppyy_test_data::get_ullong() { return m_ullong; }
-float cppyy_test_data::get_float() { return m_float; }
-double cppyy_test_data::get_double() { return m_double; }
-cppyy_test_data::what cppyy_test_data::get_enum() { return m_enum; }
-void* cppyy_test_data::get_voidp() { return m_voidp; }
+bool CppyyTestData::get_bool() { return m_bool; }
+char CppyyTestData::get_char() { return m_char; }
+signed char CppyyTestData::get_schar() { return m_schar; }
+unsigned char CppyyTestData::get_uchar() { return m_uchar; }
+short CppyyTestData::get_short() { return m_short; }
+unsigned short CppyyTestData::get_ushort() { return m_ushort; }
+int CppyyTestData::get_int() { return m_int; }
+unsigned int CppyyTestData::get_uint() { return m_uint; }
+long CppyyTestData::get_long() { return m_long; }
+unsigned long CppyyTestData::get_ulong() { return m_ulong; }
+long long CppyyTestData::get_llong() { return m_llong; }
+unsigned long long CppyyTestData::get_ullong() { return m_ullong; }
+Long64_t CppyyTestData::get_long64() { return m_long64; }
+ULong64_t CppyyTestData::get_ulong64() { return m_ulong64; }
+float CppyyTestData::get_float() { return m_float; }
+double CppyyTestData::get_double() { return m_double; }
+long double CppyyTestData::get_ldouble() { return m_ldouble; }
+CppyyTestData::EWhat CppyyTestData::get_enum() { return m_enum; }
+void* CppyyTestData::get_voidp() { return m_voidp; }
-bool* cppyy_test_data::get_bool_array() { return m_bool_array; }
-bool* cppyy_test_data::get_bool_array2() { return m_bool_array2; }
-short* cppyy_test_data::get_short_array() { return m_short_array; }
-short* cppyy_test_data::get_short_array2() { return m_short_array2; }
-unsigned short* cppyy_test_data::get_ushort_array() { return m_ushort_array; }
-unsigned short* cppyy_test_data::get_ushort_array2() { return m_ushort_array2; }
-int* cppyy_test_data::get_int_array() { return m_int_array; }
-int* cppyy_test_data::get_int_array2() { return m_int_array2; }
-unsigned int* cppyy_test_data::get_uint_array() { return m_uint_array; }
-unsigned int* cppyy_test_data::get_uint_array2() { return m_uint_array2; }
-long* cppyy_test_data::get_long_array() { return m_long_array; }
-long* cppyy_test_data::get_long_array2() { return m_long_array2; }
-unsigned long* cppyy_test_data::get_ulong_array() { return m_ulong_array; }
-unsigned long* cppyy_test_data::get_ulong_array2() { return m_ulong_array2; }
+bool* CppyyTestData::get_bool_array() { return m_bool_array; }
+bool* CppyyTestData::get_bool_array2() { return m_bool_array2; }
+short* CppyyTestData::get_short_array() { return m_short_array; }
+short* CppyyTestData::get_short_array2() { return m_short_array2; }
+unsigned short* CppyyTestData::get_ushort_array() { return m_ushort_array; }
+unsigned short* CppyyTestData::get_ushort_array2() { return m_ushort_array2; }
+int* CppyyTestData::get_int_array() { return m_int_array; }
+int* CppyyTestData::get_int_array2() { return m_int_array2; }
+unsigned int* CppyyTestData::get_uint_array() { return m_uint_array; }
+unsigned int* CppyyTestData::get_uint_array2() { return m_uint_array2; }
+long* CppyyTestData::get_long_array() { return m_long_array; }
+long* CppyyTestData::get_long_array2() { return m_long_array2; }
+unsigned long* CppyyTestData::get_ulong_array() { return m_ulong_array; }
+unsigned long* CppyyTestData::get_ulong_array2() { return m_ulong_array2; }
-float* cppyy_test_data::get_float_array() { return m_float_array; }
-float* cppyy_test_data::get_float_array2() { return m_float_array2; }
-double* cppyy_test_data::get_double_array() { return m_double_array; }
-double* cppyy_test_data::get_double_array2() { return m_double_array2; }
+float* CppyyTestData::get_float_array() { return m_float_array; }
+float* CppyyTestData::get_float_array2() { return m_float_array2; }
+double* CppyyTestData::get_double_array() { return m_double_array; }
+double* CppyyTestData::get_double_array2() { return m_double_array2; }
-cppyy_test_pod cppyy_test_data::get_pod_val() { return m_pod; }
-cppyy_test_pod* cppyy_test_data::get_pod_val_ptr() { return &m_pod; }
-cppyy_test_pod& cppyy_test_data::get_pod_val_ref() { return m_pod; }
-cppyy_test_pod*& cppyy_test_data::get_pod_ptrref() { return m_ppod; }
+CppyyTestPod CppyyTestData::get_pod_val() { return m_pod; }
+CppyyTestPod* CppyyTestData::get_pod_val_ptr() { return &m_pod; }
+CppyyTestPod& CppyyTestData::get_pod_val_ref() { return m_pod; }
+CppyyTestPod*& CppyyTestData::get_pod_ptrref() { return m_ppod; }
-cppyy_test_pod* cppyy_test_data::get_pod_ptr() { return m_ppod; }
+CppyyTestPod* CppyyTestData::get_pod_ptr() { return m_ppod; }
+
+//- getters const-ref -------------------------------------------------------
+const bool& CppyyTestData::get_bool_cr() { return m_bool; }
+const char& CppyyTestData::get_char_cr() { return m_char; }
+const signed char& CppyyTestData::get_schar_cr() { return m_schar; }
+const unsigned char& CppyyTestData::get_uchar_cr() { return m_uchar; }
+const short& CppyyTestData::get_short_cr() { return m_short; }
+const unsigned short& CppyyTestData::get_ushort_cr() { return m_ushort; }
+const int& CppyyTestData::get_int_cr() { return m_int; }
+const unsigned int& CppyyTestData::get_uint_cr() { return m_uint; }
+const long& CppyyTestData::get_long_cr() { return m_long; }
+const unsigned long& CppyyTestData::get_ulong_cr() { return m_ulong; }
+const long long& CppyyTestData::get_llong_cr() { return m_llong; }
+const unsigned long long& CppyyTestData::get_ullong_cr() { return m_ullong; }
+const Long64_t& CppyyTestData::get_long64_cr() { return m_long64; }
+const ULong64_t& CppyyTestData::get_ulong64_cr() { return m_ulong64; }
+const float& CppyyTestData::get_float_cr() { return m_float; }
+const double& CppyyTestData::get_double_cr() { return m_double; }
+const long double& CppyyTestData::get_ldouble_cr() { return m_ldouble; }
+const CppyyTestData::EWhat& CppyyTestData::get_enum_cr() { return m_enum; }
+
+//- getters ref -------------------------------------------------------------
+bool& CppyyTestData::get_bool_r() { return m_bool; }
+char& CppyyTestData::get_char_r() { return m_char; }
+signed char& CppyyTestData::get_schar_r() { return m_schar; }
+unsigned char& CppyyTestData::get_uchar_r() { return m_uchar; }
+short& CppyyTestData::get_short_r() { return m_short; }
+unsigned short& CppyyTestData::get_ushort_r() { return m_ushort; }
+int& CppyyTestData::get_int_r() { return m_int; }
+unsigned int& CppyyTestData::get_uint_r() { return m_uint; }
+long& CppyyTestData::get_long_r() { return m_long; }
+unsigned long& CppyyTestData::get_ulong_r() { return m_ulong; }
+long long& CppyyTestData::get_llong_r() { return m_llong; }
+unsigned long long& CppyyTestData::get_ullong_r() { return m_ullong; }
+Long64_t& CppyyTestData::get_long64_r() { return m_long64; }
+ULong64_t& CppyyTestData::get_ulong64_r() { return m_ulong64; }
+float& CppyyTestData::get_float_r() { return m_float; }
+double& CppyyTestData::get_double_r() { return m_double; }
+long double& CppyyTestData::get_ldouble_r() { return m_ldouble; }
+CppyyTestData::EWhat& CppyyTestData::get_enum_r() { return m_enum; }
//- setters -----------------------------------------------------------------
-void cppyy_test_data::set_bool(bool b) { m_bool = b; }
-void cppyy_test_data::set_char(char c) { m_char = c; }
-void cppyy_test_data::set_uchar(unsigned char uc) { m_uchar = uc; }
-void cppyy_test_data::set_short(short s) { m_short = s; }
-void cppyy_test_data::set_short_c(const short& s) { m_short = s; }
-void cppyy_test_data::set_ushort(unsigned short us) { m_ushort = us; }
-void cppyy_test_data::set_ushort_c(const unsigned short& us) { m_ushort = us; }
-void cppyy_test_data::set_int(int i) { m_int = i; }
-void cppyy_test_data::set_int_c(const int& i) { m_int = i; }
-void cppyy_test_data::set_uint(unsigned int ui) { m_uint = ui; }
-void cppyy_test_data::set_uint_c(const unsigned int& ui) { m_uint = ui; }
-void cppyy_test_data::set_long(long l) { m_long = l; }
-void cppyy_test_data::set_long_c(const long& l) { m_long = l; }
-void cppyy_test_data::set_ulong(unsigned long ul) { m_ulong = ul; }
-void cppyy_test_data::set_ulong_c(const unsigned long& ul) { m_ulong = ul; }
-void cppyy_test_data::set_llong(long long ll) { m_llong = ll; }
-void cppyy_test_data::set_llong_c(const long long& ll) { m_llong = ll; }
-void cppyy_test_data::set_ullong(unsigned long long ull) { m_ullong = ull; }
-void cppyy_test_data::set_ullong_c(const unsigned long long& ull) { m_ullong = ull; }
-void cppyy_test_data::set_float(float f) { m_float = f; }
-void cppyy_test_data::set_float_c(const float& f) { m_float = f; }
-void cppyy_test_data::set_double(double d) { m_double = d; }
-void cppyy_test_data::set_double_c(const double& d) { m_double = d; }
-void cppyy_test_data::set_enum(what w) { m_enum = w; }
-void cppyy_test_data::set_voidp(void* p) { m_voidp = p; }
+void CppyyTestData::set_bool(bool b) { m_bool = b; }
+void CppyyTestData::set_char(char c) { m_char = c; }
+void CppyyTestData::set_schar(signed char sc) { m_schar = sc; }
+void CppyyTestData::set_uchar(unsigned char uc) { m_uchar = uc; }
+void CppyyTestData::set_short(short s) { m_short = s; }
+void CppyyTestData::set_ushort(unsigned short us) { m_ushort = us; }
+void CppyyTestData::set_int(int i) { m_int = i; }
+void CppyyTestData::set_uint(unsigned int ui) { m_uint = ui; }
+void CppyyTestData::set_long(long l) { m_long = l; }
+void CppyyTestData::set_ulong(unsigned long ul) { m_ulong = ul; }
+void CppyyTestData::set_llong(long long ll) { m_llong = ll; }
+void CppyyTestData::set_ullong(unsigned long long ull) { m_ullong = ull; }
+void CppyyTestData::set_long64(Long64_t l64) { m_long64 = l64; }
+void CppyyTestData::set_ulong64(ULong64_t ul64) { m_ulong64 = ul64; }
+void CppyyTestData::set_float(float f) { m_float = f; }
+void CppyyTestData::set_double(double d) { m_double = d; }
+void CppyyTestData::set_ldouble(long double ld) { m_ldouble = ld; }
+void CppyyTestData::set_enum(EWhat w) { m_enum = w; }
+void CppyyTestData::set_voidp(void* p) { m_voidp = p; }
-void cppyy_test_data::set_pod_val(cppyy_test_pod p) { m_pod = p; }
-void cppyy_test_data::set_pod_ptr_in(cppyy_test_pod* pp) { m_pod = *pp; }
-void cppyy_test_data::set_pod_ptr_out(cppyy_test_pod* pp) { *pp = m_pod; }
-void cppyy_test_data::set_pod_ref(const cppyy_test_pod& rp) { m_pod = rp; }
-void cppyy_test_data::set_pod_ptrptr_in(cppyy_test_pod** ppp) { m_pod = **ppp; }
-void cppyy_test_data::set_pod_void_ptrptr_in(void** pp) { m_pod = **((cppyy_test_pod**)pp); }
-void cppyy_test_data::set_pod_ptrptr_out(cppyy_test_pod** ppp) { delete *ppp; *ppp = new cppyy_test_pod(m_pod); }
-void cppyy_test_data::set_pod_void_ptrptr_out(void** pp) { delete *((cppyy_test_pod**)pp);
- *((cppyy_test_pod**)pp) = new cppyy_test_pod(m_pod); }
+void CppyyTestData::set_pod_val(CppyyTestPod p) { m_pod = p; }
+void CppyyTestData::set_pod_ptr_in(CppyyTestPod* pp) { m_pod = *pp; }
+void CppyyTestData::set_pod_ptr_out(CppyyTestPod* pp) { *pp = m_pod; }
+void CppyyTestData::set_pod_ref(const CppyyTestPod& rp) { m_pod = rp; }
+void CppyyTestData::set_pod_ptrptr_in(CppyyTestPod** ppp) { m_pod = **ppp; }
+void CppyyTestData::set_pod_void_ptrptr_in(void** pp) { m_pod = **((CppyyTestPod**)pp); }
+void CppyyTestData::set_pod_ptrptr_out(CppyyTestPod** ppp) { delete *ppp; *ppp = new CppyyTestPod(m_pod); }
+void CppyyTestData::set_pod_void_ptrptr_out(void** pp) { delete *((CppyyTestPod**)pp);
+ *((CppyyTestPod**)pp) = new CppyyTestPod(m_pod); }
-void cppyy_test_data::set_pod_ptr(cppyy_test_pod* pp) { m_ppod = pp; }
+void CppyyTestData::set_pod_ptr(CppyyTestPod* pp) { m_ppod = pp; }
+
+//- setters const-ref -------------------------------------------------------
+void CppyyTestData::set_bool_cr(const bool& b) { m_bool = b; }
+void CppyyTestData::set_char_cr(const char& c) { m_char = c; }
+void CppyyTestData::set_schar_cr(const signed char& sc) { m_schar = sc; }
+void CppyyTestData::set_uchar_cr(const unsigned char& uc) { m_uchar = uc; }
+void CppyyTestData::set_short_cr(const short& s) { m_short = s; }
+void CppyyTestData::set_ushort_cr(const unsigned short& us) { m_ushort = us; }
+void CppyyTestData::set_int_cr(const int& i) { m_int = i; }
+void CppyyTestData::set_uint_cr(const unsigned int& ui) { m_uint = ui; }
+void CppyyTestData::set_long_cr(const long& l) { m_long = l; }
+void CppyyTestData::set_ulong_cr(const unsigned long& ul) { m_ulong = ul; }
+void CppyyTestData::set_llong_cr(const long long& ll) { m_llong = ll; }
+void CppyyTestData::set_ullong_cr(const unsigned long long& ull) { m_ullong = ull; }
+void CppyyTestData::set_long64_cr(const Long64_t& l64) { m_long64 = l64; }
+void CppyyTestData::set_ulong64_cr(const ULong64_t& ul64) { m_ulong64 = ul64; }
+void CppyyTestData::set_float_cr(const float& f) { m_float = f; }
+void CppyyTestData::set_double_cr(const double& d) { m_double = d; }
+void CppyyTestData::set_ldouble_cr(const long double& ld) { m_ldouble = ld; }
+void CppyyTestData::set_enum_cr(const EWhat& w) { m_enum = w; }
//- passers -----------------------------------------------------------------
-short* cppyy_test_data::pass_array(short* a) { return a; }
-unsigned short* cppyy_test_data::pass_array(unsigned short* a) { return a; }
-int* cppyy_test_data::pass_array(int* a) { return a; }
-unsigned int* cppyy_test_data::pass_array(unsigned int* a) { return a; }
-long* cppyy_test_data::pass_array(long* a) { return a; }
-unsigned long* cppyy_test_data::pass_array(unsigned long* a) { return a; }
-float* cppyy_test_data::pass_array(float* a) { return a; }
-double* cppyy_test_data::pass_array(double* a) { return a; }
+short* CppyyTestData::pass_array(short* a) { return a; }
+unsigned short* CppyyTestData::pass_array(unsigned short* a) { return a; }
+int* CppyyTestData::pass_array(int* a) { return a; }
+unsigned int* CppyyTestData::pass_array(unsigned int* a) { return a; }
+long* CppyyTestData::pass_array(long* a) { return a; }
+unsigned long* CppyyTestData::pass_array(unsigned long* a) { return a; }
+float* CppyyTestData::pass_array(float* a) { return a; }
+double* CppyyTestData::pass_array(double* a) { return a; }
-char cppyy_test_data::s_char = 's';
-unsigned char cppyy_test_data::s_uchar = 'u';
-short cppyy_test_data::s_short = -101;
-unsigned short cppyy_test_data::s_ushort = 255u;
-int cppyy_test_data::s_int = -202;
-unsigned int cppyy_test_data::s_uint = 202u;
-long cppyy_test_data::s_long = -303l;
-unsigned long cppyy_test_data::s_ulong = 303ul;
-long long cppyy_test_data::s_llong = -404ll;
-unsigned long long cppyy_test_data::s_ullong = 505ull;
-float cppyy_test_data::s_float = -606.f;
-double cppyy_test_data::s_double = -707.;
-cppyy_test_data::what cppyy_test_data::s_enum = cppyy_test_data::kNothing;
-void* cppyy_test_data::s_voidp = (void*)0;
+//- static data members -----------------------------------------------------
+bool CppyyTestData::s_bool = false;
+char CppyyTestData::s_char = 'c';
+signed char CppyyTestData::s_schar = 's';
+unsigned char CppyyTestData::s_uchar = 'u';
+short CppyyTestData::s_short = -101;
+unsigned short CppyyTestData::s_ushort = 255u;
+int CppyyTestData::s_int = -202;
+unsigned int CppyyTestData::s_uint = 202u;
+long CppyyTestData::s_long = -303l;
+unsigned long CppyyTestData::s_ulong = 303ul;
+long long CppyyTestData::s_llong = -404ll;
+unsigned long long CppyyTestData::s_ullong = 404ull;
+Long64_t CppyyTestData::s_long64 = -505ll;
+ULong64_t CppyyTestData::s_ulong64 = 505ull;
+float CppyyTestData::s_float = -606.f;
+double CppyyTestData::s_double = -707.;
+long double CppyyTestData::s_ldouble = -808.l;
+CppyyTestData::EWhat CppyyTestData::s_enum = CppyyTestData::kNothing;
+void* CppyyTestData::s_voidp = (void*)0;
//- strings -----------------------------------------------------------------
-const char* cppyy_test_data::get_valid_string(const char* in) { return in; }
-const char* cppyy_test_data::get_invalid_string() { return (const char*)0; }
+const char* CppyyTestData::get_valid_string(const char* in) { return in; }
+const char* CppyyTestData::get_invalid_string() { return (const char*)0; }
//= global functions ========================================================
-long get_pod_address(cppyy_test_data& c)
+long get_pod_address(CppyyTestData& c)
{
return (long)&c.m_pod;
}
-long get_int_address(cppyy_test_data& c)
+long get_int_address(CppyyTestData& c)
{
return (long)&c.m_pod.m_int;
}
-long get_double_address(cppyy_test_data& c)
+long get_double_address(CppyyTestData& c)
{
return (long)&c.m_pod.m_double;
}
+
//= global variables/pointers ===============================================
-int g_int = 42;
+bool g_bool = false;
+char g_char = 'w';
+signed char g_schar = 'v';
+unsigned char g_uchar = 'u';
+short g_short = -88;
+unsigned short g_ushort = 88u;
+int g_int = -188;
+unsigned int g_uint = 188u;
+long g_long = -288;
+unsigned long g_ulong = 288ul;
+long long g_llong = -388ll;
+unsigned long long g_ullong = 388ull;
+Long64_t g_long64 = -488ll;
+ULong64_t g_ulong64 = 488ull;
+float g_float = -588.f;
+double g_double = -688.;
+long double g_ldouble = -788.l;
+EFruit g_enum = kBanana;
+void* g_voidp = nullptr;
+
+//= global accessors ========================================================
void set_global_int(int i) {
- g_int = i;
+ g_int = i;
}
int get_global_int() {
- return g_int;
+ return g_int;
}
-cppyy_test_pod* g_pod = (cppyy_test_pod*)0;
+CppyyTestPod* g_pod = (CppyyTestPod*)0;
-bool is_global_pod(cppyy_test_pod* t) {
- return t == g_pod;
+bool is_global_pod(CppyyTestPod* t) {
+ return t == g_pod;
}
-void set_global_pod(cppyy_test_pod* t) {
- g_pod = t;
+void set_global_pod(CppyyTestPod* t) {
+ g_pod = t;
}
-cppyy_test_pod* get_global_pod() {
- return g_pod;
+CppyyTestPod* get_global_pod() {
+ return g_pod;
}
-cppyy_test_pod* get_null_pod() {
- return (cppyy_test_pod*)0;
+CppyyTestPod* get_null_pod() {
+ return (CppyyTestPod*)0;
}
diff --git a/pypy/module/cppyy/test/datatypes.h b/pypy/module/cppyy/test/datatypes.h
--- a/pypy/module/cppyy/test/datatypes.h
+++ b/pypy/module/cppyy/test/datatypes.h
@@ -1,23 +1,33 @@
+#include "RtypesCore.h"
+#include <vector>
+
const int N = 5;
//===========================================================================
-struct cppyy_test_pod {
+struct CppyyTestPod {
int m_int;
double m_double;
};
//===========================================================================
-enum fruit { kApple=78, kBanana=29, kCitrus=34 };
+enum EFruit {kApple=78, kBanana=29, kCitrus=34};
+extern std::vector<EFruit> vecFruits;
//===========================================================================
-class four_vector {
+namespace EnumSpace {
+ enum E {E1 = 1, E2};
+};
+
+
+//===========================================================================
+class FourVector {
public:
- four_vector(double x, double y, double z, double t) :
+ FourVector(double x, double y, double z, double t) :
m_cc_called(false), m_x(x), m_y(y), m_z(z), m_t(t) {}
- four_vector(const four_vector& s) :
+ FourVector(const FourVector& s) :
m_cc_called(true), m_x(s.m_x), m_y(s.m_y), m_z(s.m_z), m_t(s.m_t) {}
double operator[](int i) {
@@ -28,7 +38,7 @@
return -1;
}
- bool operator==(const four_vector& o) {
+ bool operator==(const FourVector& o) {
return (m_x == o.m_x && m_y == o.m_y &&
m_z == o.m_z && m_t == o.m_t);
}
@@ -42,13 +52,13 @@
//===========================================================================
-class cppyy_test_data {
+class CppyyTestData {
public:
- cppyy_test_data();
- ~cppyy_test_data();
+ CppyyTestData();
+ ~CppyyTestData();
// special cases
- enum what { kNothing=6, kSomething=111, kLots=42 };
+ enum EWhat { kNothing=6, kSomething=111, kLots=42 };
// helper
void destroy_arrays();
@@ -56,6 +66,7 @@
// getters
bool get_bool();
char get_char();
+ signed char get_schar();
unsigned char get_uchar();
short get_short();
unsigned short get_ushort();
@@ -65,9 +76,12 @@
unsigned long get_ulong();
long long get_llong();
unsigned long long get_ullong();
+ Long64_t get_long64();
+ ULong64_t get_ulong64();
float get_float();
double get_double();
- what get_enum();
+ long double get_ldouble();
+ EWhat get_enum();
void* get_voidp();
bool* get_bool_array();
@@ -90,50 +104,104 @@
double* get_double_array();
double* get_double_array2();
- cppyy_test_pod get_pod_val(); // for m_pod
- cppyy_test_pod* get_pod_val_ptr();
- cppyy_test_pod& get_pod_val_ref();
- cppyy_test_pod*& get_pod_ptrref();
+ CppyyTestPod get_pod_val(); // for m_pod
+ CppyyTestPod* get_pod_val_ptr();
+ CppyyTestPod& get_pod_val_ref();
+ CppyyTestPod*& get_pod_ptrref();
- cppyy_test_pod* get_pod_ptr(); // for m_ppod
+ CppyyTestPod* get_pod_ptr(); // for m_ppod
+
+// getters const-ref
+ const bool& get_bool_cr();
+ const char& get_char_cr();
+ const signed char& get_schar_cr();
+ const unsigned char& get_uchar_cr();
+ const short& get_short_cr();
+ const unsigned short& get_ushort_cr();
+ const int& get_int_cr();
+ const unsigned int& get_uint_cr();
+ const long& get_long_cr();
+ const unsigned long& get_ulong_cr();
+ const long long& get_llong_cr();
+ const unsigned long long& get_ullong_cr();
+ const Long64_t& get_long64_cr();
+ const ULong64_t& get_ulong64_cr();
+ const float& get_float_cr();
+ const double& get_double_cr();
+ const long double& get_ldouble_cr();
+ const EWhat& get_enum_cr();
+
+// getters ref
+ bool& get_bool_r();
+ char& get_char_r();
+ signed char& get_schar_r();
+ unsigned char& get_uchar_r();
+ short& get_short_r();
+ unsigned short& get_ushort_r();
+ int& get_int_r();
+ unsigned int& get_uint_r();
+ long& get_long_r();
+ unsigned long& get_ulong_r();
+ long long& get_llong_r();
+ unsigned long long& get_ullong_r();
+ Long64_t& get_long64_r();
+ ULong64_t& get_ulong64_r();
+ float& get_float_r();
+ double& get_double_r();
+ long double& get_ldouble_r();
+ EWhat& get_enum_r();
// setters
- void set_bool(bool b);
- void set_char(char c);
- void set_uchar(unsigned char uc);
- void set_short(short s);
- void set_short_c(const short& s);
- void set_ushort(unsigned short us);
- void set_ushort_c(const unsigned short& us);
- void set_int(int i);
- void set_int_c(const int& i);
- void set_uint(unsigned int ui);
- void set_uint_c(const unsigned int& ui);
- void set_long(long l);
- void set_long_c(const long& l);
- void set_llong(long long ll);
- void set_llong_c(const long long& ll);
- void set_ulong(unsigned long ul);
- void set_ulong_c(const unsigned long& ul);
- void set_ullong(unsigned long long ll);
- void set_ullong_c(const unsigned long long& ll);
- void set_float(float f);
- void set_float_c(const float& f);
- void set_double(double d);
- void set_double_c(const double& d);
- void set_enum(what w);
- void set_voidp(void* p);
+ void set_bool(bool);
+ void set_char(char);
+ void set_schar(signed char);
+ void set_uchar(unsigned char);
+ void set_short(short);
+ void set_ushort(unsigned short);
+ void set_int(int);
+ void set_uint(unsigned int);
+ void set_long(long);
+ void set_ulong(unsigned long);
+ void set_llong(long long);
+ void set_ullong(unsigned long long);
+ void set_long64(Long64_t);
+ void set_ulong64(ULong64_t);
+ void set_float(float);
+ void set_double(double);
+ void set_ldouble(long double);
+ void set_enum(EWhat);
+ void set_voidp(void*);
- void set_pod_val(cppyy_test_pod); // for m_pod
- void set_pod_ptr_in(cppyy_test_pod*);
- void set_pod_ptr_out(cppyy_test_pod*);
- void set_pod_ref(const cppyy_test_pod&);
- void set_pod_ptrptr_in(cppyy_test_pod**);
+ void set_pod_val(CppyyTestPod); // for m_pod
+ void set_pod_ptr_in(CppyyTestPod*);
+ void set_pod_ptr_out(CppyyTestPod*);
+ void set_pod_ref(const CppyyTestPod&);
+ void set_pod_ptrptr_in(CppyyTestPod**);
void set_pod_void_ptrptr_in(void**);
- void set_pod_ptrptr_out(cppyy_test_pod**);
+ void set_pod_ptrptr_out(CppyyTestPod**);
void set_pod_void_ptrptr_out(void**);
- void set_pod_ptr(cppyy_test_pod*); // for m_ppod
+ void set_pod_ptr(CppyyTestPod*); // for m_ppod
+
+// setters const-ref
+ void set_bool_cr(const bool&);
+ void set_char_cr(const char&);
+ void set_schar_cr(const signed char&);
+ void set_uchar_cr(const unsigned char&);
+ void set_short_cr(const short&);
+ void set_ushort_cr(const unsigned short&);
+ void set_int_cr(const int&);
+ void set_uint_cr(const unsigned int&);
+ void set_long_cr(const long&);
+ void set_ulong_cr(const unsigned long&);
+ void set_llong_cr(const long long&);
+ void set_ullong_cr(const unsigned long long&);
+ void set_long64_cr(const Long64_t&);
+ void set_ulong64_cr(const ULong64_t&);
+ void set_float_cr(const float&);
+ void set_double_cr(const double&);
+ void set_ldouble_cr(const long double&);
+ void set_enum_cr(const EWhat&);
// passers
short* pass_array(short*);
@@ -162,6 +230,7 @@
// basic types
bool m_bool;
char m_char;
+ signed char m_schar;
unsigned char m_uchar;
short m_short;
unsigned short m_ushort;
@@ -171,9 +240,12 @@
unsigned long m_ulong;
long long m_llong;
unsigned long long m_ullong;
+ Long64_t m_long64;
+ ULong64_t m_ulong64;
float m_float;
double m_double;
- what m_enum;
+ long double m_ldouble;
+ EWhat m_enum;
void* m_voidp;
// array types
@@ -191,18 +263,20 @@
long* m_long_array2;
unsigned long m_ulong_array[N];
unsigned long* m_ulong_array2;
-
+
float m_float_array[N];
float* m_float_array2;
double m_double_array[N];
double* m_double_array2;
// object types
- cppyy_test_pod m_pod;
- cppyy_test_pod* m_ppod;
+ CppyyTestPod m_pod;
+ CppyyTestPod* m_ppod;
public:
+ static bool s_bool;
static char s_char;
+ static signed char s_schar;
static unsigned char s_uchar;
static short s_short;
static unsigned short s_ushort;
@@ -212,9 +286,12 @@
static unsigned long s_ulong;
static long long s_llong;
static unsigned long long s_ullong;
+ static Long64_t s_long64;
+ static ULong64_t s_ulong64;
static float s_float;
static double s_double;
- static what s_enum;
+ static long double s_ldouble;
+ static EWhat s_enum;
static void* s_voidp;
private:
@@ -223,18 +300,59 @@
//= global functions ========================================================
-long get_pod_address(cppyy_test_data& c);
-long get_int_address(cppyy_test_data& c);
-long get_double_address(cppyy_test_data& c);
+long get_pod_address(CppyyTestData& c);
+long get_int_address(CppyyTestData& c);
+long get_double_address(CppyyTestData& c);
//= global variables/pointers ===============================================
-extern int g_int;
+extern bool g_bool;
+extern char g_char;
+extern signed char g_schar;
+extern unsigned char g_uchar;
+extern short g_short;
+extern unsigned short g_ushort;
+extern int g_int;
+extern unsigned int g_uint;
+extern long g_long;
+extern unsigned long g_ulong;
+extern long long g_llong;
+extern unsigned long long g_ullong;
+extern Long64_t g_long64;
+extern ULong64_t g_ulong64;
+extern float g_float;
+extern double g_double;
+extern long double g_ldouble;
+extern EFruit g_enum;
+extern void* g_voidp;
+
+static const bool g_c_bool = true;
+static const char g_c_char = 'z';
+static const signed char g_c_schar = 'y';
+static const unsigned char g_c_uchar = 'x';
+static const short g_c_short = -99;
+static const unsigned short g_c_ushort = 99u;
+static const int g_c_int = -199;
+static const unsigned int g_c_uint = 199u;
+static const long g_c_long = -299;
+static const unsigned long g_c_ulong = 299ul;
+static const long long g_c_llong = -399ll;
+static const unsigned long long g_c_ullong = 399ull;
+static const Long64_t g_c_long64 = -499ll;
+static const ULong64_t g_c_ulong64 = 499ull;
+static const float g_c_float = -599.f;
+static const double g_c_double = -699.;
+static const long double g_c_ldouble = -799.l;
+static const EFruit g_c_enum = kApple;
+static const void* g_c_voidp = nullptr;
+
+
+//= global accessors ========================================================
void set_global_int(int i);
int get_global_int();
-extern cppyy_test_pod* g_pod;
-bool is_global_pod(cppyy_test_pod* t);
-void set_global_pod(cppyy_test_pod* t);
-cppyy_test_pod* get_global_pod();
-cppyy_test_pod* get_null_pod();
+extern CppyyTestPod* g_pod;
+bool is_global_pod(CppyyTestPod* t);
+void set_global_pod(CppyyTestPod* t);
+CppyyTestPod* get_global_pod();
+CppyyTestPod* get_null_pod();
diff --git a/pypy/module/cppyy/test/datatypes.xml b/pypy/module/cppyy/test/datatypes.xml
--- a/pypy/module/cppyy/test/datatypes.xml
+++ b/pypy/module/cppyy/test/datatypes.xml
@@ -1,9 +1,9 @@
<lcgdict>
- <class pattern="cppyy_test_*" />
- <class name="four_vector" />
+ <class pattern="CppyyTest*" />
+ <class name="FourVector" />
- <enum name="fruit" />
+ <enum name="EFruit" />
<function pattern="get_*" />
<function pattern="set_*" />
diff --git a/pypy/module/cppyy/test/test_datatypes.py b/pypy/module/cppyy/test/test_datatypes.py
--- a/pypy/module/cppyy/test/test_datatypes.py
+++ b/pypy/module/cppyy/test/test_datatypes.py
@@ -31,10 +31,10 @@
"""Test read access to instance public data and verify values"""
import cppyy
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
- assert isinstance(c, cppyy_test_data)
+ c = CppyyTestData()
+ assert isinstance(c, CppyyTestData)
# reading boolean type
assert c.m_bool == False
@@ -51,7 +51,7 @@
assert c.m_long == -33
assert c.m_ulong == 33
assert c.m_llong == -44
- assert c.m_ullong == 55
+ assert c.m_ullong == 44
# reading floating point types
assert round(c.m_float + 66., 5) == 0
@@ -106,11 +106,11 @@
raises(IndexError, c.m_double_array.__getitem__, self.N)
# can not access an instance member on the class
- raises(ReferenceError, getattr, cppyy_test_data, 'm_bool')
- raises(ReferenceError, getattr, cppyy_test_data, 'm_int')
+ raises(ReferenceError, getattr, CppyyTestData, 'm_bool')
+ raises(ReferenceError, getattr, CppyyTestData, 'm_int')
- assert not hasattr(cppyy_test_data, 'm_bool')
- assert not hasattr(cppyy_test_data, 'm_int')
+ assert not hasattr(CppyyTestData, 'm_bool')
+ assert not hasattr(CppyyTestData, 'm_int')
c.destruct()
@@ -118,10 +118,10 @@
"""Test write access to instance public data and verify values"""
import cppyy
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
- assert isinstance(c, cppyy_test_data)
+ c = CppyyTestData()
+ assert isinstance(c, CppyyTestData)
# boolean types through functions
c.set_bool(True); assert c.get_bool() == True
@@ -165,7 +165,7 @@
assert eval('c.m_%s' % names[i]) == 2*i
for i in range(len(names)):
- exec 'c.set_%s_c(%d)' % (names[i],3*i)
+ exec 'c.set_%s_cr(%d)' % (names[i],3*i)
assert eval('c.m_%s' % names[i]) == 3*i
# float types through functions
@@ -173,12 +173,12 @@
c.set_double( 0.456 ); assert round(c.get_double() - 0.456, 8) == 0
# float types through data members
- c.m_float = 0.123; assert round(c.get_float() - 0.123, 5) == 0
- c.set_float(0.234); assert round(c.m_float - 0.234, 5) == 0
- c.set_float_c(0.456); assert round(c.m_float - 0.456, 5) == 0
- c.m_double = 0.678; assert round(c.get_double() - 0.678, 8) == 0
- c.set_double(0.890); assert round(c.m_double - 0.890, 8) == 0
- c.set_double_c(0.012); assert round(c.m_double - 0.012, 8) == 0
+ c.m_float = 0.123; assert round(c.get_float() - 0.123, 5) == 0
+ c.set_float(0.234); assert round(c.m_float - 0.234, 5) == 0
+ c.set_float_cr(0.456); assert round(c.m_float - 0.456, 5) == 0
+ c.m_double = 0.678; assert round(c.get_double() - 0.678, 8) == 0
+ c.set_double(0.890); assert round(c.m_double - 0.890, 8) == 0
+ c.set_double_cr(0.012); assert round(c.m_double - 0.012, 8) == 0
# arrays; there will be pointer copies, so destroy the current ones
c.destroy_arrays()
@@ -205,10 +205,10 @@
"""Test passing of array arguments"""
import cppyy, array, sys
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
- assert isinstance(c, cppyy_test_data)
+ c = CppyyTestData()
+ assert isinstance(c, CppyyTestData)
a = range(self.N)
# test arrays in mixed order, to give overload resolution a workout
@@ -243,39 +243,39 @@
"""Test read access to class public data and verify values"""
import cppyy, sys
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
- assert isinstance(c, cppyy_test_data)
+ c = CppyyTestData()
+ assert isinstance(c, CppyyTestData)
# char types
- assert cppyy_test_data.s_char == 's'
- assert c.s_char == 's'
+ assert CppyyTestData.s_char == 'c'
+ assert c.s_char == 'c'
assert c.s_uchar == 'u'
- assert cppyy_test_data.s_uchar == 'u'
+ assert CppyyTestData.s_uchar == 'u'
# integer types
- assert cppyy_test_data.s_short == -101
+ assert CppyyTestData.s_short == -101
assert c.s_short == -101
assert c.s_ushort == 255
- assert cppyy_test_data.s_ushort == 255
- assert cppyy_test_data.s_int == -202
+ assert CppyyTestData.s_ushort == 255
+ assert CppyyTestData.s_int == -202
assert c.s_int == -202
assert c.s_uint == 202
- assert cppyy_test_data.s_uint == 202
- assert cppyy_test_data.s_long == -303L
+ assert CppyyTestData.s_uint == 202
+ assert CppyyTestData.s_long == -303L
assert c.s_long == -303L
assert c.s_ulong == 303L
- assert cppyy_test_data.s_ulong == 303L
- assert cppyy_test_data.s_llong == -404L
+ assert CppyyTestData.s_ulong == 303L
+ assert CppyyTestData.s_llong == -404L
assert c.s_llong == -404L
- assert c.s_ullong == 505L
- assert cppyy_test_data.s_ullong == 505L
+ assert c.s_ullong == 404L
+ assert CppyyTestData.s_ullong == 404L
# floating point types
- assert round(cppyy_test_data.s_float + 606., 5) == 0
+ assert round(CppyyTestData.s_float + 606., 5) == 0
assert round(c.s_float + 606., 5) == 0
- assert round(cppyy_test_data.s_double + 707., 8) == 0
+ assert round(CppyyTestData.s_double + 707., 8) == 0
assert round(c.s_double + 707., 8) == 0
c.destruct()
@@ -284,62 +284,62 @@
"""Test write access to class public data and verify values"""
import cppyy, sys
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
- assert isinstance(c, cppyy_test_data)
+ c = CppyyTestData()
+ assert isinstance(c, CppyyTestData)
# char types
- cppyy_test_data.s_char = 'a'
+ CppyyTestData.s_char = 'a'
assert c.s_char == 'a'
c.s_char = 'b'
- assert cppyy_test_data.s_char == 'b'
- cppyy_test_data.s_uchar = 'c'
+ assert CppyyTestData.s_char == 'b'
+ CppyyTestData.s_uchar = 'c'
assert c.s_uchar == 'c'
c.s_uchar = 'd'
- assert cppyy_test_data.s_uchar == 'd'
- raises(ValueError, setattr, cppyy_test_data, 's_uchar', -1)
+ assert CppyyTestData.s_uchar == 'd'
+ raises(ValueError, setattr, CppyyTestData, 's_uchar', -1)
raises(ValueError, setattr, c, 's_uchar', -1)
# integer types
c.s_short = -102
- assert cppyy_test_data.s_short == -102
- cppyy_test_data.s_short = -203
+ assert CppyyTestData.s_short == -102
+ CppyyTestData.s_short = -203
assert c.s_short == -203
c.s_ushort = 127
- assert cppyy_test_data.s_ushort == 127
- cppyy_test_data.s_ushort = 227
+ assert CppyyTestData.s_ushort == 127
+ CppyyTestData.s_ushort = 227
assert c.s_ushort == 227
- cppyy_test_data.s_int = -234
+ CppyyTestData.s_int = -234
assert c.s_int == -234
c.s_int = -321
- assert cppyy_test_data.s_int == -321
- cppyy_test_data.s_uint = 1234
+ assert CppyyTestData.s_int == -321
+ CppyyTestData.s_uint = 1234
assert c.s_uint == 1234
c.s_uint = 4321
- assert cppyy_test_data.s_uint == 4321
+ assert CppyyTestData.s_uint == 4321
raises(ValueError, setattr, c, 's_uint', -1)
- raises(ValueError, setattr, cppyy_test_data, 's_uint', -1)
- cppyy_test_data.s_long = -87L
+ raises(ValueError, setattr, CppyyTestData, 's_uint', -1)
+ CppyyTestData.s_long = -87L
assert c.s_long == -87L
c.s_long = 876L
- assert cppyy_test_data.s_long == 876L
- cppyy_test_data.s_ulong = 876L
+ assert CppyyTestData.s_long == 876L
+ CppyyTestData.s_ulong = 876L
assert c.s_ulong == 876L
c.s_ulong = 678L
- assert cppyy_test_data.s_ulong == 678L
- raises(ValueError, setattr, cppyy_test_data, 's_ulong', -1)
+ assert CppyyTestData.s_ulong == 678L
+ raises(ValueError, setattr, CppyyTestData, 's_ulong', -1)
raises(ValueError, setattr, c, 's_ulong', -1)
# floating point types
- cppyy_test_data.s_float = -3.1415
+ CppyyTestData.s_float = -3.1415
assert round(c.s_float, 5 ) == -3.1415
c.s_float = 3.1415
- assert round(cppyy_test_data.s_float, 5 ) == 3.1415
+ assert round(CppyyTestData.s_float, 5 ) == 3.1415
import math
c.s_double = -math.pi
- assert cppyy_test_data.s_double == -math.pi
- cppyy_test_data.s_double = math.pi
+ assert CppyyTestData.s_double == -math.pi
+ CppyyTestData.s_double = math.pi
assert c.s_double == math.pi
c.destruct()
@@ -348,10 +348,10 @@
"""Test the ranges of integer types"""
import cppyy, sys
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
- assert isinstance(c, cppyy_test_data)
+ c = CppyyTestData()
+ assert isinstance(c, CppyyTestData)
# TODO: should these be TypeErrors, or should char/bool raise
# ValueErrors? In any case, consistency is needed ...
@@ -364,10 +364,10 @@
"""Test conversions between builtin types"""
import cppyy, sys
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
- assert isinstance(c, cppyy_test_data)
+ c = CppyyTestData()
+ assert isinstance(c, CppyyTestData)
c.m_double = -1
assert round(c.m_double + 1.0, 8) == 0
@@ -402,7 +402,7 @@
raises(ReferenceError, 'gbl.g_pod.m_int')
- c = gbl.cppyy_test_pod()
+ c = gbl.CppyyTestPod()
c.m_int = 42
c.m_double = 3.14
@@ -416,7 +416,7 @@
assert c == d
assert id(c) == id(d)
- e = gbl.cppyy_test_pod()
+ e = gbl.CppyyTestPod()
e.m_int = 43
e.m_double = 2.14
@@ -431,44 +431,44 @@
import cppyy
gbl = cppyy.gbl
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
- assert isinstance(c, cppyy_test_data)
+ c = CppyyTestData()
+ assert isinstance(c, CppyyTestData)
# test that the enum is accessible as a type
- assert cppyy_test_data.what
+ assert CppyyTestData.EWhat
- assert cppyy_test_data.kNothing == 6
- assert cppyy_test_data.kSomething == 111
- assert cppyy_test_data.kLots == 42
+ assert CppyyTestData.kNothing == 6
+ assert CppyyTestData.kSomething == 111
+ assert CppyyTestData.kLots == 42
- assert cppyy_test_data.what(cppyy_test_data.kNothing) == cppyy_test_data.kNothing
- assert cppyy_test_data.what(6) == cppyy_test_data.kNothing
+ assert CppyyTestData.EWhat(CppyyTestData.kNothing) == CppyyTestData.kNothing
+ assert CppyyTestData.EWhat(6) == CppyyTestData.kNothing
# TODO: only allow instantiations with correct values (C++11)
- assert c.get_enum() == cppyy_test_data.kNothing
- assert c.m_enum == cppyy_test_data.kNothing
+ assert c.get_enum() == CppyyTestData.kNothing
+ assert c.m_enum == CppyyTestData.kNothing
- c.m_enum = cppyy_test_data.kSomething
- assert c.get_enum() == cppyy_test_data.kSomething
- assert c.m_enum == cppyy_test_data.kSomething
+ c.m_enum = CppyyTestData.kSomething
+ assert c.get_enum() == CppyyTestData.kSomething
+ assert c.m_enum == CppyyTestData.kSomething
- c.set_enum(cppyy_test_data.kLots)
- assert c.get_enum() == cppyy_test_data.kLots
- assert c.m_enum == cppyy_test_data.kLots
+ c.set_enum(CppyyTestData.kLots)
+ assert c.get_enum() == CppyyTestData.kLots
+ assert c.m_enum == CppyyTestData.kLots
- assert c.s_enum == cppyy_test_data.s_enum
- assert c.s_enum == cppyy_test_data.kNothing
- assert cppyy_test_data.s_enum == cppyy_test_data.kNothing
+ assert c.s_enum == CppyyTestData.s_enum
+ assert c.s_enum == CppyyTestData.kNothing
+ assert CppyyTestData.s_enum == CppyyTestData.kNothing
- c.s_enum = cppyy_test_data.kSomething
- assert c.s_enum == cppyy_test_data.s_enum
- assert c.s_enum == cppyy_test_data.kSomething
- assert cppyy_test_data.s_enum == cppyy_test_data.kSomething
+ c.s_enum = CppyyTestData.kSomething
+ assert c.s_enum == CppyyTestData.s_enum
+ assert c.s_enum == CppyyTestData.kSomething
+ assert CppyyTestData.s_enum == CppyyTestData.kSomething
# global enums
- assert gbl.fruit # test type accessible
+ assert gbl.EFruit # test type accessible
assert gbl.kApple == 78
assert gbl.kBanana == 29
assert gbl.kCitrus == 34
@@ -477,9 +477,9 @@
"""Test passing/returning of a const char*"""
import cppyy
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
+ c = CppyyTestData()
assert c.get_valid_string('aap') == 'aap'
#assert c.get_invalid_string() == ''
@@ -487,11 +487,11 @@
"""Test copy constructor"""
import cppyy
- four_vector = cppyy.gbl.four_vector
+ FourVector = cppyy.gbl.FourVector
- t1 = four_vector(1., 2., 3., -4.)
- t2 = four_vector(0., 0., 0., 0.)
- t3 = four_vector(t1)
+ t1 = FourVector(1., 2., 3., -4.)
+ t2 = FourVector(0., 0., 0., 0.)
+ t3 = FourVector(t1)
assert t1 == t3
assert t1 != t2
@@ -504,7 +504,7 @@
import cppyy
- c = cppyy.gbl.cppyy_test_data()
+ c = cppyy.gbl.CppyyTestData()
assert c.m_pod.m_int == 888
assert c.m_pod.m_double == 3.14
@@ -531,11 +531,11 @@
import cppyy
- c = cppyy.gbl.cppyy_test_data()
+ c = cppyy.gbl.CppyyTestData()
assert c.m_pod.m_int == 888
assert c.m_pod.m_double == 3.14
- p = cppyy.gbl.cppyy_test_pod()
+ p = cppyy.gbl.CppyyTestPod()
p.m_int = 123
assert p.m_int == 123
p.m_double = 321.
@@ -545,12 +545,12 @@
assert c.m_pod.m_int == 123
assert c.m_pod.m_double == 321.
- c = cppyy.gbl.cppyy_test_data()
+ c = cppyy.gbl.CppyyTestData()
c.set_pod_ptr_in(p)
assert c.m_pod.m_int == 123
assert c.m_pod.m_double == 321.
- c = cppyy.gbl.cppyy_test_data()
+ c = cppyy.gbl.CppyyTestData()
c.set_pod_ptr_out(p)
assert p.m_int == 888
assert p.m_double == 3.14
@@ -558,26 +558,26 @@
p.m_int = 555
p.m_double = 666.
- c = cppyy.gbl.cppyy_test_data()
+ c = cppyy.gbl.CppyyTestData()
c.set_pod_ref(p)
assert c.m_pod.m_int == 555
assert c.m_pod.m_double == 666.
- c = cppyy.gbl.cppyy_test_data()
+ c = cppyy.gbl.CppyyTestData()
c.set_pod_ptrptr_in(p)
assert c.m_pod.m_int == 555
assert c.m_pod.m_double == 666.
assert p.m_int == 555
assert p.m_double == 666.
- c = cppyy.gbl.cppyy_test_data()
+ c = cppyy.gbl.CppyyTestData()
c.set_pod_void_ptrptr_in(p)
assert c.m_pod.m_int == 555
assert c.m_pod.m_double == 666.
assert p.m_int == 555
assert p.m_double == 666.
- c = cppyy.gbl.cppyy_test_data()
+ c = cppyy.gbl.CppyyTestData()
c.set_pod_ptrptr_out(p)
assert c.m_pod.m_int == 888
assert c.m_pod.m_double == 3.14
@@ -587,7 +587,7 @@
p.m_int = 777
p.m_double = 888.
- c = cppyy.gbl.cppyy_test_data()
+ c = cppyy.gbl.CppyyTestData()
c.set_pod_void_ptrptr_out(p)
assert c.m_pod.m_int == 888
assert c.m_pod.m_double == 3.14
@@ -600,7 +600,7 @@
import cppyy
for o in (0, None):
- c = cppyy.gbl.cppyy_test_data()
+ c = cppyy.gbl.CppyyTestData()
assert c.m_pod.m_int == 888
assert c.m_pod.m_double == 3.14
assert not not c.m_ppod
@@ -613,10 +613,10 @@
"""Test that privacy settings are respected"""
import cppyy
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
- assert isinstance(c, cppyy_test_data)
+ c = CppyyTestData()
+ assert isinstance(c, CppyyTestData)
raises(AttributeError, getattr, c, 'm_owns_arrays')
@@ -628,29 +628,29 @@
import cppyy
gbl = cppyy.gbl
- c1 = cppyy.bind_object(0, gbl.cppyy_test_data)
+ c1 = cppyy.bind_object(0, gbl.CppyyTestData)
assert c1 == None
assert None == c1
- c2 = cppyy.bind_object(0, gbl.cppyy_test_data)
+ c2 = cppyy.bind_object(0, gbl.CppyyTestData)
assert c1 == c2
assert c2 == c1
- # four_vector overrides operator==
- l1 = cppyy.bind_object(0, gbl.four_vector)
+ # FourVector overrides operator==
+ l1 = cppyy.bind_object(0, gbl.FourVector)
assert l1 == None
assert None == l1
assert c1 != l1
assert l1 != c1
- l2 = cppyy.bind_object(0, gbl.four_vector)
+ l2 = cppyy.bind_object(0, gbl.FourVector)
assert l1 == l2
assert l2 == l1
- l3 = gbl.four_vector(1, 2, 3, 4)
- l4 = gbl.four_vector(1, 2, 3, 4)
- l5 = gbl.four_vector(4, 3, 2, 1)
+ l3 = gbl.FourVector(1, 2, 3, 4)
+ l4 = gbl.FourVector(1, 2, 3, 4)
+ l5 = gbl.FourVector(4, 3, 2, 1)
assert l3 == l4
assert l4 == l3
@@ -664,7 +664,7 @@
from cppyy import gbl
- d = gbl.cppyy_test_pod()
+ d = gbl.CppyyTestPod()
assert d
assert not not d
@@ -677,9 +677,9 @@
"""Test usage of buffer sizing"""
import cppyy
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
+ c = CppyyTestData()
for func in ['get_bool_array', 'get_bool_array2',
'get_ushort_array', 'get_ushort_array2',
'get_int_array', 'get_int_array2',
@@ -698,19 +698,19 @@
"""Test usage of void* data"""
import cppyy
- cppyy_test_data = cppyy.gbl.cppyy_test_data
+ CppyyTestData = cppyy.gbl.CppyyTestData
- c = cppyy_test_data()
+ c = CppyyTestData()
assert not cppyy.gbl.nullptr
assert c.s_voidp is cppyy.gbl.nullptr
- assert cppyy_test_data.s_voidp is cppyy.gbl.nullptr
+ assert CppyyTestData.s_voidp is cppyy.gbl.nullptr
assert c.m_voidp is cppyy.gbl.nullptr
assert c.get_voidp() is cppyy.gbl.nullptr
- c2 = cppyy_test_data()
+ c2 = CppyyTestData()
assert c2.m_voidp is cppyy.gbl.nullptr
c.set_voidp(c2.m_voidp)
assert c.m_voidp is cppyy.gbl.nullptr
@@ -722,9 +722,9 @@
c.set_voidp(c2)
def address_equality_test(a, b):
assert cppyy.addressof(a) == cppyy.addressof(b)
- b2 = cppyy.bind_object(a, cppyy_test_data)
+ b2 = cppyy.bind_object(a, CppyyTestData)
assert b is b2 # memory regulator recycles
- b3 = cppyy.bind_object(cppyy.addressof(a), cppyy_test_data)
+ b3 = cppyy.bind_object(cppyy.addressof(a), CppyyTestData)
assert b is b3 # likewise
address_equality_test(c.m_voidp, c2)
More information about the pypy-commit
mailing list