[pypy-commit] pypy reflex-support: make namespace lookup work for CINT back-end

wlav noreply at buildbot.pypy.org
Thu Aug 18 01:20:01 CEST 2011


Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r46579:ddc85152823f
Date: 2011-08-16 16:33 -0700
http://bitbucket.org/pypy/pypy/changeset/ddc85152823f/

Log:	make namespace lookup work for CINT back-end

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
@@ -59,8 +59,8 @@
 
 static inline char* type_cppstring_to_cstring(const std::string& tname) {
     G__TypeInfo ti(tname.c_str());
-    std::string name = ti.IsValid() ? ti.TrueName() : tname;
-    return cppstring_to_cstring(name);
+    std::string true_name = ti.IsValid() ? ti.TrueName() : tname;
+    return cppstring_to_cstring(true_name);
 }
 
 static inline TClassRef type_from_handle(cppyy_typehandle_t handle) {
@@ -270,8 +270,13 @@
 /* type/class reflection information -------------------------------------- */
 char* cppyy_final_name(cppyy_typehandle_t handle) {
     TClassRef cr = type_from_handle(handle);
-    if (cr.GetClass() && cr->GetClassInfo())
-        return type_cppstring_to_cstring(cr->GetName());
+    if (cr.GetClass() && cr->GetClassInfo()) {
+        std::string true_name = G__TypeInfo(cr->GetName()).TrueName();
+        std::string::size_type pos = true_name.rfind("::");
+        if (pos != std::string::npos)
+            return cppstring_to_cstring(true_name.substr(pos+2, std::string::npos));
+        return cppstring_to_cstring(true_name);
+    }
     return cppstring_to_cstring(cr.GetClassName());
 }
 
diff --git a/pypy/module/cppyy/test/Makefile b/pypy/module/cppyy/test/Makefile
--- a/pypy/module/cppyy/test/Makefile
+++ b/pypy/module/cppyy/test/Makefile
@@ -38,6 +38,9 @@
 #
 # rootcint -f datatypes_cint.cxx -c datatypes.h datatypes_LinkDef.h
 # g++ -I$ROOTSYS/include datatypes_cint.cxx datatypes.cxx -shared -o datatypesDict.so -rdynamic
+#
+# rootcint -f advancedcpp_cint.cxx -c advancedcpp.h advancedcpp_LinkDef.h
+# g++ -I$ROOTSYS/include advancedcpp_cint.cxx advancedcpp.cxx -shared -o advancedcppDict.so -rdynamic
 
 # TODO: methptrgetter causes these tests to crash, so don't use it for now
 stltypesDict.so: stltypes.cxx stltypes.h stltypes.xml
diff --git a/pypy/module/cppyy/test/advancedcpp.h b/pypy/module/cppyy/test/advancedcpp.h
--- a/pypy/module/cppyy/test/advancedcpp.h
+++ b/pypy/module/cppyy/test/advancedcpp.h
@@ -87,10 +87,10 @@
    int m_d;
 };
 
-int get_a( a_class& a );
-int get_b( b_class& b );
-int get_c( c_class& c );
-int get_d( d_class& d );
+int get_a(a_class& a);
+int get_b(b_class& b);
+int get_c(c_class& c);
+int get_d(d_class& d);
 
 
 //===========================================================================


More information about the pypy-commit mailing list