[pypy-commit] pypy reflex-support: translation fixes and extra test to catch them earlier next time

wlav noreply at buildbot.pypy.org
Wed Apr 25 00:44:29 CEST 2012


Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r54739:c606b30252d7
Date: 2012-04-24 11:48 -0700
http://bitbucket.org/pypy/pypy/changeset/c606b30252d7/

Log:	translation fixes and extra test to catch them earlier next time

diff --git a/pypy/module/cppyy/capi/__init__.py b/pypy/module/cppyy/capi/__init__.py
--- a/pypy/module/cppyy/capi/__init__.py
+++ b/pypy/module/cppyy/capi/__init__.py
@@ -243,7 +243,7 @@
 
 _c_base_offset = rffi.llexternal(
     "cppyy_base_offset",
-    [C_TYPE, C_TYPE, C_OBJECT, rffi.INT], rffi.LONG,
+    [C_TYPE, C_TYPE, C_OBJECT, rffi.INT], rffi.SIZE_T,
     threadsafe=threadsafe,
     compilation_info=backend.eci,
     elidable_function=True)
diff --git a/pypy/module/cppyy/include/capi.h b/pypy/module/cppyy/include/capi.h
--- a/pypy/module/cppyy/include/capi.h
+++ b/pypy/module/cppyy/include/capi.h
@@ -61,7 +61,7 @@
     int cppyy_is_subtype(cppyy_type_t derived, cppyy_type_t base);
 
     /* calculate offsets between declared and actual type, up-cast: direction > 0; down-cast: direction < 0 */
-    long cppyy_base_offset(cppyy_type_t derived, cppyy_type_t base, cppyy_object_t address, int direction);
+    size_t cppyy_base_offset(cppyy_type_t derived, cppyy_type_t base, cppyy_object_t address, int direction);
 
     /* method/function reflection information --------------------------------- */
     int cppyy_num_methods(cppyy_scope_t scope);
diff --git a/pypy/module/cppyy/interp_cppyy.py b/pypy/module/cppyy/interp_cppyy.py
--- a/pypy/module/cppyy/interp_cppyy.py
+++ b/pypy/module/cppyy/interp_cppyy.py
@@ -449,7 +449,7 @@
         for f in overload.functions:
             if 0 < f.signature().find(sig):
                 return W_CPPOverload(self.space, self, [f])
-        raise OperationError(space.w_TypeError, space.wrap("no overload matches signature"))
+        raise OperationError(self.space.w_TypeError, self.space.wrap("no overload matches signature"))
 
     def missing_attribute_error(self, name):
         return OperationError(
@@ -616,6 +616,7 @@
     get_datamember_names = interp2app(W_ComplexCPPClass.get_datamember_names, unwrap_spec=['self']),
     get_datamember = interp2app(W_ComplexCPPClass.get_datamember, unwrap_spec=['self', str]),
     is_namespace = interp2app(W_ComplexCPPClass.is_namespace, unwrap_spec=['self']),
+    dispatch = interp2app(W_CPPClass.dispatch, unwrap_spec=['self', str, str]),
 )
 W_ComplexCPPClass.typedef.acceptable_as_base_class = False
 
diff --git a/pypy/module/cppyy/src/cintcwrapper.cxx b/pypy/module/cppyy/src/cintcwrapper.cxx
--- a/pypy/module/cppyy/src/cintcwrapper.cxx
+++ b/pypy/module/cppyy/src/cintcwrapper.cxx
@@ -467,7 +467,7 @@
     return derived_type->GetBaseClass(base_type) != 0;
 }
 
-long cppyy_base_offset(cppyy_type_t derived_handle, cppyy_type_t base_handle,
+size_t cppyy_base_offset(cppyy_type_t derived_handle, cppyy_type_t base_handle,
                        cppyy_object_t address, int /* direction */) {
     // WARNING: CINT can not handle actual dynamic casts!
     TClassRef derived_type = type_from_handle(derived_handle);
@@ -494,7 +494,7 @@
          }
     }
 
-    return offset;
+    return (size_t) offset;   // may be negative (will roll over)
 }
 
 
diff --git a/pypy/module/cppyy/src/reflexcwrapper.cxx b/pypy/module/cppyy/src/reflexcwrapper.cxx
--- a/pypy/module/cppyy/src/reflexcwrapper.cxx
+++ b/pypy/module/cppyy/src/reflexcwrapper.cxx
@@ -277,7 +277,7 @@
     return (int)derived_type.HasBase(base_type);
 }
 
-long cppyy_base_offset(cppyy_type_t derived_handle, cppyy_type_t base_handle,
+size_t cppyy_base_offset(cppyy_type_t derived_handle, cppyy_type_t base_handle,
                        cppyy_object_t address, int direction) {
     Reflex::Type derived_type = type_from_handle(derived_handle);
     Reflex::Type base_type = type_from_handle(base_handle);
@@ -303,8 +303,8 @@
             if (ibase->first.ToType() == base_type) {
                 long offset = (long)ibase->first.Offset((void*)address);
                 if (direction < 0)
-                    return -offset;
-                return offset;
+                   return (size_t) -offset;  // note negative; rolls over
+                return (size_t)offset;
             }
         }
 
diff --git a/pypy/module/cppyy/test/test_overloads.py b/pypy/module/cppyy/test/test_overloads.py
--- a/pypy/module/cppyy/test/test_overloads.py
+++ b/pypy/module/cppyy/test/test_overloads.py
@@ -59,6 +59,7 @@
 
         c = c_overload()
         raises(TypeError, c.__dispatch__, 'get_int', 12)
+        raises(TypeError, c.__dispatch__, 'get_int', 'does_not_exist')
         assert c.__dispatch__('get_int', 'a_overload*')(a_overload()) == 42
         assert c.__dispatch__('get_int', 'b_overload*')(b_overload()) == 13
 


More information about the pypy-commit mailing list