Author: Wim Lavrijsen <[email protected]>
Branch: cling-support
Changeset: r86296:1eaa1b5ee34f
Date: 2016-08-18 14:17 -0700
http://bitbucket.org/pypy/pypy/changeset/1eaa1b5ee34f/

Log:    change handling of std; fixes access to cout

diff --git a/pypy/module/cppyy/pythonify.py b/pypy/module/cppyy/pythonify.py
--- a/pypy/module/cppyy/pythonify.py
+++ b/pypy/module/cppyy/pythonify.py
@@ -440,7 +440,7 @@
     gbl = make_cppnamespace(None, "::", None, False)   # global C++ namespace
     gbl.__doc__ = "Global C++ namespace."
 
-    # mostly for the benefit of the CINT backend, which treats std as special
+    # pre-create std to allow direct importing
     gbl.std = make_cppnamespace(None, "std", None, False)
 
     # install a type for enums to refer to
diff --git a/pypy/module/cppyy/src/clingcwrapper.cxx 
b/pypy/module/cppyy/src/clingcwrapper.cxx
--- a/pypy/module/cppyy/src/clingcwrapper.cxx
+++ b/pypy/module/cppyy/src/clingcwrapper.cxx
@@ -70,9 +70,10 @@
       assert( g_classrefs.size() == GLOBAL_HANDLE );
       g_name2classrefidx[ "" ]      = GLOBAL_HANDLE;
       g_classrefs.push_back(TClassRef(""));
-      // ROOT ignores std/::std, so point them to the global namespace
-      g_name2classrefidx[ "std" ]   = GLOBAL_HANDLE;
-      g_name2classrefidx[ "::std" ] = GLOBAL_HANDLE;
+      // aliases for std (setup already in pythonify)
+      g_name2classrefidx[ "std" ]   = GLOBAL_HANDLE+1;
+      g_name2classrefidx[ "::std" ] = GLOBAL_HANDLE+1;
+      g_classrefs.push_back(TClassRef("std"));
       // add a dummy global to refer to as null at index 0
       g_globalvars.push_back( nullptr );
    }
@@ -1012,8 +1013,10 @@
 
 Cppyy::TCppIndex_t Cppyy::GetDatamemberIndex( TCppScope_t scope, const 
std::string& name )
 {
+   std::cout << " ASKING FOR: " << name << " on scope: " << scope << std::endl;
    if ( scope == GLOBAL_HANDLE ) {
       TGlobal* gb = (TGlobal*)gROOT->GetListOfGlobals( kTRUE )->FindObject( 
name.c_str() );
+      std::cout << " FOUND (G): "<< gb << " " << 
(TGlobal*)gROOT->GetListOfGlobals( kTRUE )->FindObject("std::cout") << 
std::endl;
       if ( gb && gb->GetAddress() && gb->GetAddress() != (void*)-1 ) {
          g_globalvars.push_back( gb );
          return g_globalvars.size() - 1;
@@ -1025,6 +1028,7 @@
          TDataMember* dm =
             (TDataMember*)cr->GetListOfDataMembers()->FindObject( name.c_str() 
);
          // TODO: turning this into an index is silly ...
+         std::cout << " FOUND (D): "<< dm << std::endl;
          if ( dm ) return (TCppIndex_t)cr->GetListOfDataMembers()->IndexOf( dm 
);
       }
    }
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
@@ -62,14 +62,12 @@
 
 endif
 
-ifeq ($(CLING),)
 ifeq ($(DUMMY),)
 # TODO: methptrgetter causes these tests to crash, so don't use it for now
 std_streamsDict.so: std_streams.cxx std_streams.h std_streams.xml
        $(genreflex) std_streams.h --selection=std_streams.xml
        g++ -o $@ std_streams_rflx.cpp std_streams.cxx -shared -std=c++14 
$(cppflags) $(cppflags2)
 endif
-endif
 
 .PHONY: clean
 clean:
diff --git a/pypy/module/cppyy/test/std_streams.xml 
b/pypy/module/cppyy/test/std_streams.xml
--- a/pypy/module/cppyy/test/std_streams.xml
+++ b/pypy/module/cppyy/test/std_streams.xml
@@ -1,9 +1,12 @@
 <lcgdict>
 
+  <namespace name = "std" />
+
   <class name = "std::ostream"/>
   <class name = "std::ios_base"/>
   <class name = "std::basic_ios<char,std::char_traits<char> >"/>
 
+  <class name = "std::basic_ostream<char,char_traits<char> >" />
   <variable name="std::cout" />
 
 </lcgdict>
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to