[pypy-svn] r76208 - in pypy/branch/reflex-support/pypy/module/cppyy: . include src test

wlav at codespeak.net wlav at codespeak.net
Wed Jul 14 17:29:53 CEST 2010


Author: wlav
Date: Wed Jul 14 17:29:51 2010
New Revision: 76208

Added:
   pypy/branch/reflex-support/pypy/module/cppyy/test/datatypes.cxx   (contents, props changed)
   pypy/branch/reflex-support/pypy/module/cppyy/test/datatypes.h   (contents, props changed)
   pypy/branch/reflex-support/pypy/module/cppyy/test/test_datatypes.py   (contents, props changed)
Modified:
   pypy/branch/reflex-support/pypy/module/cppyy/capi.py
   pypy/branch/reflex-support/pypy/module/cppyy/converter.py
   pypy/branch/reflex-support/pypy/module/cppyy/executor.py
   pypy/branch/reflex-support/pypy/module/cppyy/include/reflexcwrapper.h
   pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx
   pypy/branch/reflex-support/pypy/module/cppyy/test/Makefile
   pypy/branch/reflex-support/pypy/module/cppyy/test/test_cppyy.py
   pypy/branch/reflex-support/pypy/module/cppyy/test/test_pythonify.py
Log:
Preparation of new test for the builtin datatypes (modified from roottest), and a bool executor/converter.


Modified: pypy/branch/reflex-support/pypy/module/cppyy/capi.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/capi.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/capi.py	Wed Jul 14 17:29:51 2010
@@ -45,6 +45,10 @@
     "cppyy_call_v",
     [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP], lltype.Void,
     compilation_info=eci)
+c_call_b = rffi.llexternal(
+    "cppyy_call_b",
+    [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP], rffi.INT,
+    compilation_info=eci)
 c_call_l = rffi.llexternal(
     "cppyy_call_l",
     [C_TYPEHANDLE, rffi.INT, C_OBJECT, rffi.INT, rffi.VOIDPP], rffi.LONG,

Modified: pypy/branch/reflex-support/pypy/module/cppyy/converter.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/converter.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/converter.py	Wed Jul 14 17:29:51 2010
@@ -13,12 +13,22 @@
         lltype.free(arg, flavor='raw')
 
 
+class BoolConverter(TypeConverter):
+    def convert_argument(self, space, w_obj):
+        arg = space.c_int_w(w_obj)
+        if arg != False and arg != True:
+            raise OperationError(space.w_TypeError,
+                                 space.wrap("boolean value should be bool, or integer 1 or 0"))
+        x = lltype.malloc(rffi.LONGP.TO, 1, flavor='raw')
+        x[0] = arg
+        return rffi.cast(rffi.VOIDP, x)
+
 class IntConverter(TypeConverter):
     def convert_argument(self, space, w_obj):
         arg = space.c_int_w(w_obj)
         x = lltype.malloc(rffi.LONGP.TO, 1, flavor='raw')
         x[0] = arg
-        return rffi.cast(rffi.VOIDP, x)        
+        return rffi.cast(rffi.VOIDP, x)
 
 class DoubleConverter(TypeConverter):
     def convert_argument(self, space, w_obj):
@@ -33,6 +43,7 @@
         x = rffi.str2charp(arg)
         return rffi.cast(rffi.VOIDP, x)
 
+
 class InstancePtrConverter(TypeConverter):
     _immutable_ = True
     def __init__(self, space, cpptype):
@@ -76,6 +87,7 @@
 
     raise OperationError(space.w_TypeError, space.wrap("no clue what %s is" % name))
 
+_converters["bool"]                = BoolConverter()
 _converters["int"]                 = IntConverter()
 _converters["double"]              = DoubleConverter()
 _converters["const char*"]         = CStringConverter()

Modified: pypy/branch/reflex-support/pypy/module/cppyy/executor.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/executor.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/executor.py	Wed Jul 14 17:29:51 2010
@@ -15,6 +15,11 @@
         capi.c_call_v(func.cpptype.handle, func.method_index, cppthis, num_args, args)
         return space.w_None
 
+class BoolExecutor(FunctionExecutor):
+    def execute(self, space, func, cppthis, num_args, args):
+        result = capi.c_call_b(func.cpptype.handle, func.method_index, cppthis, num_args, args)
+        return space.wrap(result)
+
 class LongExecutor(FunctionExecutor):
     def execute(self, space, func, cppthis, num_args, args):
         result = capi.c_call_l(func.cpptype.handle, func.method_index, cppthis, num_args, args)
@@ -63,7 +68,8 @@
  #  raise TypeError("no clue what %s is" % name)
 
 _executors["void"]                = VoidExecutor()
+_executors["bool"]                = BoolExecutor()
 _executors["int"]                 = LongExecutor()
-_executors["long"]                = LongExecutor()
+_executors["long int"]            = LongExecutor()
 _executors["double"]              = DoubleExecutor()
 _executors["char*"]               = CStringExecutor()

Modified: pypy/branch/reflex-support/pypy/module/cppyy/include/reflexcwrapper.h
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/include/reflexcwrapper.h	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/include/reflexcwrapper.h	Wed Jul 14 17:29:51 2010
@@ -14,8 +14,9 @@
     void* cppyy_allocate(cppyy_typehandle_t handle);
     void cppyy_deallocate(cppyy_typehandle_t handle, cppyy_object_t instance);
 
-    void cppyy_call_v(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
-    long cppyy_call_l(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
+    void   cppyy_call_v(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
+    int    cppyy_call_b(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
+    long   cppyy_call_l(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
     double cppyy_call_d(cppyy_typehandle_t handle, int method_index, cppyy_object_t self, int numargs, void* args[]);
     void cppyy_destruct(cppyy_typehandle_t handle, cppyy_object_t self);
     cppyy_methptrgetter_t cppyy_get_methptr_getter(cppyy_typehandle_t handle, int method_index);

Modified: pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx	Wed Jul 14 17:29:51 2010
@@ -31,9 +31,10 @@
     }
 }
 
-long cppyy_call_l(cppyy_typehandle_t handle, int method_index,
-                  cppyy_object_t self, int numargs, void* args[]) {
-    long result;
+template<typename T>
+static inline T cppyy_call_T(cppyy_typehandle_t handle, int method_index,
+                             cppyy_object_t self, int numargs, void* args[]) {
+    T result;
     std::vector<void*> arguments(args, args+numargs);
     Reflex::Type t((Reflex::TypeName*)handle);
     Reflex::Member m = t.FunctionMemberAt(method_index);
@@ -46,19 +47,19 @@
     return result;
 }
 
+int cppyy_call_b(cppyy_typehandle_t handle, int method_index,
+                  cppyy_object_t self, int numargs, void* args[]) {
+    return (int)cppyy_call_T<bool>(handle, method_index, self, numargs, args);
+}
+
+long cppyy_call_l(cppyy_typehandle_t handle, int method_index,
+                  cppyy_object_t self, int numargs, void* args[]) {
+    return cppyy_call_T<long>(handle, method_index, self, numargs, args);
+}
+
 double cppyy_call_d(cppyy_typehandle_t handle, int method_index,
                     cppyy_object_t self, int numargs, void* args[]) {
-    double result;
-    std::vector<void*> arguments(args, args+numargs);
-    Reflex::Type t((Reflex::TypeName*)handle);
-    Reflex::Member m = t.FunctionMemberAt(method_index);
-    if (self) {
-        Reflex::Object o(t, self);
-        m.Invoke(o, result, arguments);
-    } else {
-        m.Invoke(result, arguments);
-    }
-    return result;
+    return cppyy_call_T<double>(handle, method_index, self, numargs, args);
 }   
 
 void cppyy_destruct(cppyy_typehandle_t handle, cppyy_object_t self) {

Modified: pypy/branch/reflex-support/pypy/module/cppyy/test/Makefile
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/test/Makefile	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/test/Makefile	Wed Jul 14 17:29:51 2010
@@ -1,3 +1,5 @@
+all: example01Dict.so datatypesDict.so
+
 ROOTSYS := ${ROOTSYS}
 
 ifeq ($(ROOTSYS),)
@@ -19,3 +21,7 @@
 example01Dict.so: example01.cxx example01.h
 	$(genreflex) example01.h $(genreflexflags)
 	g++ -o $@ example01_rflx.cpp example01.cxx -shared -lReflex $(cppflags) $(cppflags2)
+
+datatypesDict.so: datatypes.cxx datatypes.h
+	$(genreflex) datatypes.h $(genreflexflags)
+	g++ -o $@ datatypes_rflx.cpp datatypes.cxx -shared -lReflex $(cppflags) $(cppflags2)

Added: pypy/branch/reflex-support/pypy/module/cppyy/test/datatypes.cxx
==============================================================================
--- (empty file)
+++ pypy/branch/reflex-support/pypy/module/cppyy/test/datatypes.cxx	Wed Jul 14 17:29:51 2010
@@ -0,0 +1,143 @@
+#include "datatypes.h"
+
+
+cppyy_test_data::cppyy_test_data() : 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_float  = -44.f;
+    m_double = -55.;
+
+    m_short_array2  = new short[N];
+    m_ushort_array2 = new unsigned short[N];
+    m_int_array2    = new int[N];
+    m_uint_array2   = new unsigned int[N];
+    m_long_array2   = new long[N];
+    m_ulong_array2  = new unsigned long[N];
+
+    m_float_array2  = new float[N];
+    m_double_array2 = new double[N];
+
+    for (int i = 0; i < N; ++i) {
+        m_short_array[i]   =  -1*i;
+        m_short_array2[i]  =  -2*i;
+        m_ushort_array[i]  =   3u*i;
+        m_ushort_array2[i] =   4u*i;
+        m_int_array[i]     =  -5*i;
+        m_int_array2[i]    =  -6*i;
+        m_uint_array[i]    =   7u*i;
+        m_uint_array2[i]   =   8u*i;
+        m_long_array[i]    =  -9l*i;
+        m_long_array2[i]   = -10l*i;
+        m_ulong_array[i]   =  11ul*i;
+        m_ulong_array2[i]  =  12ul*i;
+
+        m_float_array[i]   = -13.f*i;
+        m_float_array2[i]  = -14.f*i;
+        m_double_array[i]  = -15.*i;
+        m_double_array2[i] = -16.*i;
+    }
+
+    m_owns_arrays = true;
+
+    m_pod.m_int    = 888;
+    m_pod.m_double = 3.14;
+};
+
+cppyy_test_data::~cppyy_test_data()
+{
+    destroy_arrays();
+}
+
+void cppyy_test_data::destroy_arrays() {
+    if (m_owns_arrays == true) {
+        delete[] m_short_array2;
+        delete[] m_ushort_array2;
+        delete[] m_int_array2;
+        delete[] m_uint_array2;
+        delete[] m_long_array2;
+        delete[] m_ulong_array2;
+
+        delete[] m_float_array2;
+        delete[] m_double_array2;
+
+        m_owns_arrays = false;
+    }
+}
+
+// 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; }
+float          cppyy_test_data::get_float()  { return m_float; }
+double         cppyy_test_data::get_double() { return m_double; }
+
+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; }
+
+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; }
+
+// 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_ushort(unsigned short us) { m_ushort = us; }
+void cppyy_test_data::set_int(int i)                { m_int    = i; }
+void cppyy_test_data::set_uint(unsigned int ui)     { m_uint   = ui; }
+void cppyy_test_data::set_long(long l)              { m_long   = l; }
+void cppyy_test_data::set_ulong(unsigned long ul)   { m_ulong  = ul; }
+void cppyy_test_data::set_float(float f)            { m_float  = f; }
+void cppyy_test_data::set_double(double d)          { m_double = d; }
+
+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;
+float          cppyy_test_data::s_float  = -404.f;
+double         cppyy_test_data::s_double = -505.;
+
+long get_pod_address(cppyy_test_data& c)
+{
+    return (long)&c.m_pod;
+}
+
+long get_int_address(cppyy_test_data& c)
+{
+    return (long)&c.m_pod.m_int;
+}
+
+long get_double_address(cppyy_test_data& c)
+{
+    return (long)&c.m_pod.m_double;
+}

Added: pypy/branch/reflex-support/pypy/module/cppyy/test/datatypes.h
==============================================================================
--- (empty file)
+++ pypy/branch/reflex-support/pypy/module/cppyy/test/datatypes.h	Wed Jul 14 17:29:51 2010
@@ -0,0 +1,120 @@
+const int N = 5;
+
+
+//===========================================================================
+struct cppyy_test_pod {
+   int    m_int;
+   double m_double;
+};
+
+
+//===========================================================================
+class cppyy_test_data {
+public:
+    cppyy_test_data();
+    ~cppyy_test_data();
+
+// getters
+    bool           get_bool();
+    char           get_char();
+    unsigned char  get_uchar();
+    short          get_short();
+    unsigned short get_ushort();
+    int            get_int();
+    unsigned int   get_uint();
+    long           get_long();
+    unsigned long  get_ulong();
+    float          get_float();
+    double         get_double();
+
+    short*          get_short_array();
+    short*          get_short_array2();
+    unsigned short* get_ushort_array();
+    unsigned short* get_ushort_array2();
+    int*            get_int_array();
+    int*            get_int_array2();
+    unsigned int*   get_uint_array();
+    unsigned int*   get_uint_array2();
+    long*           get_long_array();
+    long*           get_long_array2();
+    unsigned long*  get_ulong_array();
+    unsigned long*  get_ulong_array2();
+
+    float*  get_float_array();
+    float*  get_float_array2();
+    double* get_double_array();
+    double* get_double_array2();
+
+// setters
+    void set_bool(bool b);
+    void set_char(char c);
+    void set_uchar(unsigned char uc);
+    void set_short(short s);
+    void set_ushort(unsigned short us);
+    void set_int(int i);
+    void set_uint(unsigned int ui);
+    void set_long(long l);
+    void set_ulong(unsigned long ul);
+    void set_float(float f);
+    void set_double(double d);
+
+public:
+// basic types
+    bool           m_bool;
+    char           m_char;
+    unsigned char  m_uchar;
+    short          m_short;
+    unsigned short m_ushort;
+    int            m_int;
+    unsigned int   m_uint;
+    long           m_long;
+    unsigned long  m_ulong;
+    float          m_float;
+    double         m_double;
+
+// array types
+    short           m_short_array[N];
+    short*          m_short_array2;
+    unsigned short  m_ushort_array[N];
+    unsigned short* m_ushort_array2;
+    int             m_int_array[N];
+    int*            m_int_array2;
+    unsigned int    m_uint_array[N];
+    unsigned int*   m_uint_array2;
+    long            m_long_array[N];
+    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;
+
+public:
+    static char           s_char;
+    static unsigned char  s_uchar;
+    static short          s_short;
+    static unsigned short s_ushort;
+    static int            s_int;
+    static unsigned int   s_uint;
+    static long           s_long;
+    static unsigned long  s_ulong;
+    static float          s_float;
+    static double         s_double;
+
+private:
+    void destroy_arrays();
+
+private:
+    bool m_owns_arrays;
+};
+
+
+// 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);

Modified: pypy/branch/reflex-support/pypy/module/cppyy/test/test_cppyy.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/test/test_cppyy.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/test/test_cppyy.py	Wed Jul 14 17:29:51 2010
@@ -11,7 +11,7 @@
 def setup_module(mod):
     if sys.platform == 'win32':
         py.test.skip("win32 not supported so far")
-    err = os.system("cd '%s' && make" % currpath)
+    err = os.system("cd '%s' && make example01Dict.so" % currpath)
     if err:
         raise OSError("'make' failed (see stderr)")
 

Added: pypy/branch/reflex-support/pypy/module/cppyy/test/test_datatypes.py
==============================================================================
--- (empty file)
+++ pypy/branch/reflex-support/pypy/module/cppyy/test/test_datatypes.py	Wed Jul 14 17:29:51 2010
@@ -0,0 +1,105 @@
+import py, os, sys
+from pypy.conftest import gettestobjspace
+from pypy.module.cppyy import interp_cppyy, executor
+
+
+currpath = py.path.local(__file__).dirpath()
+shared_lib = str(currpath.join("datatypesDict.so"))
+
+space = gettestobjspace(usemodules=['cppyy'])
+
+def setup_module(mod):
+    if sys.platform == 'win32':
+        py.test.skip("win32 not supported so far")
+    err = os.system("cd '%s' && make datatypesDict.so" % currpath)
+    if err:
+        raise OSError("'make' failed (see stderr)")
+
+class AppTestDATATYPES:
+    N = 5               # should be imported from the dictionary
+
+    def setup_class(cls):
+        cls.space = space
+        env = os.environ
+        cls.w_shared_lib = space.wrap(shared_lib)
+        cls.w_datatypes = cls.space.appexec([], """():
+            import cppyy
+            return cppyy.load_lib(%r)""" % (shared_lib, ))
+
+    def testLoadLibCache(self):
+        """Test whether loading a library twice results in the same object."""
+        import cppyy
+        lib2 = cppyy.load_lib(self.shared_lib)
+        assert self.datatypes is lib2
+
+    def test2WriteAccess( self ):
+        """Test write access to instance public data and verify values"""
+
+        import cppyy, sys
+        cppyy_test_data = cppyy.gbl.cppyy_test_data
+
+        c = cppyy_test_data()
+        assert isinstance(c, cppyy_test_data)
+
+        # boolean types
+        c.set_bool(True);
+        assert c.get_bool() == True
+        c.set_bool(0);     assert c.get_bool() == False
+        """
+        c.m_bool = True;   assert c.get_bool() == True
+        c.set_bool(True);  assert c.m_bool     == True
+        c.m_bool = 0;      assert c.get_bool() == False
+        c.set_bool(0);     assert c.m_bool     == False
+        """
+        raises(TypeError, 'c.set_bool(10)')
+
+        """
+        # char types
+        c.m_char = 'b';    assert c.get_char()  ==     'b'
+        c.m_char = 40;     assert c.get_char()  == chr(40)
+        c.set_char('c');   assert c.m_char      ==     'c'
+        c.set_char(41);    assert c.m_char      == chr(41)
+        c.m_uchar = 'd';   assert c.get_uchar() ==     'd'
+        c.m_uchar = 42;    assert c.get_uchar() == chr(42)
+        c.set_uchar('e');  assert c.m_uchar     ==     'e'
+        c.set_uchar(43);   assert c.m_uchar     == chr(43)
+
+        raises(TypeError, 'c.set_char("string")')
+        raises(TypeError, 'c.set_uchar(-1)')
+        raises(TypeError, 'c.set_uchar("string")')
+
+        # integer types
+        names = ['short', 'ushort', 'int', 'uint', 'long', 'ulong']
+        for i in range(len(names)):
+            exec 'c.m_%s = %d' % (names[i],i)
+            assert eval('c.get_%s()' % names[i]) == i
+
+        for i in range(len(names)):
+            exec 'c.set_%s = %d' % (names[i],2*i)
+            assert eval('c.m_%s' % names[i]) == i
+
+        # float types
+        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.m_double = 0.456;    assert round(c.get_double() - 0.456, 8) == 0
+        c.set_double( 0.567 ); assert round(c.m_double     - 0.567, 8) == 0
+
+        # arrays; there will be pointer copies, so destroy the current ones
+        c.destroy_arrays()
+
+        # integer arrays
+        a = range(N)
+        atypes = [ 'h', 'H', 'i', 'I', 'l', 'L' ]
+        for j in range(len(names)):
+            b = array(atypes[j], a)
+            exec 'c.m_%s_array = b' % names[j]   # buffer copies
+            for i in range(N):
+                assert eval('c.m_%s_array[i]' % names[j]) == b[i]
+
+            exec 'c.m_%s_array2 = b' % names[j]  # pointer copies
+            b[i] = 28
+            for i in range(N):
+                assert eval('c.m_%s_array2[i]' % names[j]) == b[i]
+        """
+
+        c.destruct()

Modified: pypy/branch/reflex-support/pypy/module/cppyy/test/test_pythonify.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/test/test_pythonify.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/test/test_pythonify.py	Wed Jul 14 17:29:51 2010
@@ -1,4 +1,4 @@
-import py, os
+import py, os, sys
 from pypy.conftest import gettestobjspace
 from pypy.module.cppyy import interp_cppyy, executor
 
@@ -9,7 +9,11 @@
 space = gettestobjspace(usemodules=['cppyy'])
 
 def setup_module(mod):
-    os.system("make")
+    if sys.platform == 'win32':
+        py.test.skip("win32 not supported so far")
+    err = os.system("cd '%s' && make example01Dict.so" % currpath)
+    if err:
+        raise OSError("'make' failed (see stderr)")
 
 class AppTestPYTHONIFY:
     def setup_class(cls):



More information about the Pypy-commit mailing list